Initial commit

This commit is contained in:
2021-08-01 17:19:21 -04:00
commit 48bdeeba33
36 changed files with 23143 additions and 0 deletions

1
blog/event-bus/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
node_modules/

30
blog/event-bus/index.js Normal file
View 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

File diff suppressed because it is too large Load Diff

View 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"
}
}