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/index.js
ivaosthu 37f9ed9570 Implement cookie-session support.
Sessions will be required to solve admin-auth.

I also refactored a few middlewares into seperate
files to make the code easier to read.

closes #262
2020-02-20 08:34:04 +01:00

37 lines
1021 B
JavaScript

'use strict';
const { Router } = require('express');
const features = require('./feature.js');
const featureArchive = require('./archive.js');
const events = require('./event.js');
const strategies = require('./strategy');
const metrics = require('./metrics');
const apiDef = {
version: 2,
links: {
'feature-toggles': { uri: '/api/admin/features' },
'feature-archive': { uri: '/api/admin/archive' },
strategies: { uri: '/api/admin/strategies' },
events: { uri: '/api/admin/events' },
metrics: { uri: '/api/admin/metrics' },
},
};
exports.apiDef = apiDef;
exports.router = config => {
const router = Router();
router.get('/', (req, res) => res.json(apiDef));
router.use('/features', features.router(config));
router.use('/archive', featureArchive.router(config));
router.use('/strategies', strategies.router(config));
router.use('/events', events.router(config));
router.use('/metrics', metrics.router(config));
return router;
};