Initial commit
This commit is contained in:
1
blog/event-bus/.gitignore
vendored
Normal file
1
blog/event-bus/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules/
|
||||
30
blog/event-bus/index.js
Normal file
30
blog/event-bus/index.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
const axios = require('axios');
|
||||
|
||||
const app = express();
|
||||
app.use(bodyParser.json());
|
||||
|
||||
const events = [];
|
||||
|
||||
app.post('/events', (req, res) => {
|
||||
const event = req.body;
|
||||
|
||||
events.push(event);
|
||||
|
||||
axios.post('http://localhost:4000/events', event).catch(error => console.log(error));
|
||||
axios.post('http://localhost:4001/events', event).catch(error => console.log(error));
|
||||
axios.post('http://localhost:4002/events', event).catch(error => console.log(error));
|
||||
axios.post('http://localhost:4003/events', event).catch(error => console.log(error));
|
||||
|
||||
res.send({status: 'OK'});
|
||||
});
|
||||
|
||||
app.get('/events', (req, res) => {
|
||||
res.send(events);
|
||||
});
|
||||
|
||||
|
||||
app.listen(4005, () => {
|
||||
console.log('Listening on 4005');
|
||||
});
|
||||
1242
blog/event-bus/package-lock.json
generated
Normal file
1242
blog/event-bus/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
blog/event-bus/package.json
Normal file
16
blog/event-bus/package.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "event-bus",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "nodemon index.js"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"express": "^4.17.1",
|
||||
"nodemon": "^2.0.9"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user