mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
0546100556
relates to #102
26 lines
705 B
JavaScript
26 lines
705 B
JavaScript
'use strict';
|
|
const eventDiffer = require('../eventDiffer');
|
|
const version = 1;
|
|
|
|
module.exports = function (app, config) {
|
|
const eventDb = config.eventDb;
|
|
|
|
app.get('/events', (req, res) => {
|
|
eventDb.getEvents().then(events => {
|
|
eventDiffer.addDiffs(events);
|
|
res.json({ version, events });
|
|
});
|
|
});
|
|
|
|
app.get('/events/:name', (req, res) => {
|
|
eventDb.getEventsFilterByName(req.params.name).then(events => {
|
|
if (events) {
|
|
eventDiffer.addDiffs(events);
|
|
res.json(events);
|
|
} else {
|
|
res.status(404).json({ error: 'Could not find events' });
|
|
}
|
|
});
|
|
});
|
|
};
|