1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/packages/unleash-api/lib/routes/event.js
2020-02-20 08:30:26 +01:00

25 lines
677 B
JavaScript

'use strict';
const eventDiffer = require('../eventDiffer');
module.exports = function (app, config) {
const eventDb = config.eventDb;
app.get('/events', (req, res) => {
eventDb.getEvents().then(events => {
eventDiffer.addDiffs(events);
res.json({ 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' });
}
});
});
};