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

31 lines
831 B
JavaScript

'use strict';
const eventDiffer = require('../event-differ');
const version = 1;
module.exports = function (app, config) {
const { eventStore } = config.stores;
app.get('/events', (req, res) => {
eventStore.getEvents().then(events => {
eventDiffer.addDiffs(events);
res.json({ version, events });
});
});
app.get('/events/:name', (req, res) => {
const toggleName = req.params.name;
eventStore.getEventsFilterByName(toggleName).then(events => {
if (events) {
eventDiffer.addDiffs(events);
res.json({
toggleName,
events,
});
} else {
res.status(404).json({ error: 'Could not find events' });
}
});
});
};