-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (28 loc) · 807 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const express = require('express');
const axios = require('axios');
const app = express();
app.use(express.json());
const events = [];
app.post('/events', (req, res) => {
const event = req.body;
events.push(event);
axios.post('http://posts-clusterip-srv:4000/events', event).catch((e) => {
console.log(e.message);
});
axios.post('http://comments-srv:4001/events', event).catch((e) => {
console.log(e.message);
});
axios.post('http://query-srv:4002/events', event).catch((e) => {
console.log(e.message);
});
axios.post('http://moderation-srv:4003/events', event).catch((e) => {
console.log(e.message);
});
res.send({ status: 'OK' });
});
app.get('/events', (req, res) => {
res.send(events);
});
app.listen(4005, () => {
console.log('Listening on 4005');
});