2016-06-18 21:53:18 +02:00
|
|
|
'use strict';
|
|
|
|
|
2017-06-28 10:20:22 +02:00
|
|
|
const { Router } = require('express');
|
2016-11-09 22:31:49 +01:00
|
|
|
|
2017-06-28 10:20:22 +02:00
|
|
|
const adminApi = require('./admin-api');
|
|
|
|
const clientApi = require('./client-api');
|
|
|
|
const clientFeatures = require('./client-api/feature.js');
|
|
|
|
|
|
|
|
const health = require('./health-check');
|
|
|
|
const backstage = require('./backstage.js');
|
|
|
|
|
|
|
|
exports.router = function(config) {
|
|
|
|
const router = Router();
|
|
|
|
|
|
|
|
router.use('/health', health.router(config));
|
|
|
|
router.use('/internal-backstage', backstage.router(config));
|
|
|
|
|
|
|
|
router.get('/api', (req, res) => {
|
|
|
|
res.json({
|
|
|
|
version: 2,
|
|
|
|
links: {
|
|
|
|
admin: {
|
|
|
|
uri: '/api/admin',
|
|
|
|
links: adminApi.apiDef.links,
|
|
|
|
},
|
|
|
|
client: {
|
|
|
|
uri: '/api/client',
|
|
|
|
links: clientApi.apiDef.links,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
router.use('/api/admin', adminApi.router(config));
|
|
|
|
router.use('/api/client', clientApi.router(config));
|
|
|
|
|
|
|
|
// legacy support
|
|
|
|
// $root/features
|
|
|
|
// $root/client/register
|
|
|
|
// $root/client/metrics
|
|
|
|
router.use('/api/features', clientFeatures.router(config));
|
2016-11-09 22:31:49 +01:00
|
|
|
|
2017-06-28 10:20:22 +02:00
|
|
|
return router;
|
2016-04-28 16:58:59 +02:00
|
|
|
};
|