1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/lib/routes/index.js
2020-03-29 22:22:19 +02:00

36 lines
1.2 KiB
JavaScript

'use strict';
const AdminApi = require('./admin-api');
const ClientApi = require('./client-api');
const FeatureController = require('./client-api/feature.js');
const Controller = require('./controller');
const HealthCheckController = require('./health-check');
const BackstageCTR = require('./backstage.js');
const LogoutController = require('./logout');
const api = require('./api-def');
class IndexRouter extends Controller {
constructor(config) {
super();
this.use('/health', new HealthCheckController(config).router);
this.use('/internal-backstage', new BackstageCTR(config).router);
this.use('/logout', new LogoutController(config).router);
this.get(api.uri, this.index);
this.use(api.links.admin.uri, new AdminApi(config).router);
this.use(api.links.client.uri, new ClientApi(config).router);
// legacy support (remove in 4.x)
if (config.enableLegacyRoutes) {
const featureController = new FeatureController(config.stores);
this.use('/api/features', featureController.router);
}
}
index(req, res) {
res.json(api);
}
}
module.exports = IndexRouter;