-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (35 loc) · 1.18 KB
/
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
37
38
39
40
41
42
43
44
45
46
var express = require('express');
var app = express();
const port = process.env.PORT || 3001;
const EventService = require('./services/eventService')
const HeroService = require('./services/heroService')
const heroService = new HeroService()
const eventService = new EventService(heroService)
let events = []
app.use(express.json());
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.get('/health', function (req, res) {
res.send("OK !");
});
app.post('/event', function (req, res) {
console.log('Event: ',req.body);
eventService.handleEvent(req.body)
res.send("Event received!");
});
app.post('/registration', function (req, res) {
console.log('registration: ',req.body);
heroService.registerHero(req.body)
console.log(heroService.getHeroes())
res.send("Hero received!");
});
app.get('/interventionPlan', function (req, res) {
console.log('intervention plan');
res.send(eventService.getInterventionPlan())
});
app.listen(port, function () {
console.log('API mocks app listening on port 3001!')
});