1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/lib/routes/admin-api/event.js

36 lines
965 B
JavaScript
Raw Normal View History

2016-06-18 21:53:18 +02:00
'use strict';
2016-10-26 10:43:11 +02:00
const Controller = require('../controller');
const eventDiffer = require('../../event-differ');
const version = 1;
2014-10-24 15:32:33 +02:00
class EventController extends Controller {
constructor(config) {
super(config);
this.eventStore = config.stores.eventStore;
this.get('/', this.getEvents);
this.get('/:name', this.getEventsForToggle);
}
async getEvents(req, res) {
const events = await this.eventStore.getEvents();
eventDiffer.addDiffs(events);
res.json({ version, events });
}
2014-11-14 07:13:08 +01:00
async getEventsForToggle(req, res) {
2016-12-05 17:58:29 +01:00
const toggleName = req.params.name;
const events = await this.eventStore.getEventsFilterByName(toggleName);
if (events) {
eventDiffer.addDiffs(events);
res.json({ toggleName, events });
} else {
res.status(404).json({ error: 'Could not find events' });
}
}
}
module.exports = EventController;