2016-06-18 21:53:18 +02:00
|
|
|
'use strict';
|
|
|
|
|
2018-11-29 21:25:45 +01:00
|
|
|
const AdminApi = require('./admin-api');
|
2018-11-24 15:45:22 +01:00
|
|
|
const ClientApi = require('./client-api');
|
2018-11-24 15:02:31 +01:00
|
|
|
const FeatureController = require('./client-api/feature.js');
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2018-12-03 08:59:13 +01:00
|
|
|
const Controller = require('./controller');
|
2018-11-24 12:43:46 +01:00
|
|
|
const HealthCheckController = require('./health-check');
|
2018-11-29 21:25:45 +01:00
|
|
|
const BackstageCTR = require('./backstage.js');
|
|
|
|
const api = require('./api-def');
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2018-12-03 08:59:13 +01:00
|
|
|
class IndexRouter extends Controller {
|
2018-11-24 12:58:30 +01:00
|
|
|
constructor(config) {
|
2018-12-03 08:59:13 +01:00
|
|
|
super();
|
|
|
|
this.use('/health', new HealthCheckController(config).router);
|
|
|
|
this.use('/internal-backstage', new BackstageCTR(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);
|
2018-11-24 12:58:30 +01:00
|
|
|
|
|
|
|
// legacy support (remove in 4.x)
|
|
|
|
if (config.enableLegacyRoutes) {
|
2018-12-03 08:59:13 +01:00
|
|
|
const featureController = new FeatureController(config.stores);
|
|
|
|
this.use('/api/features', featureController.router);
|
2018-11-24 12:58:30 +01:00
|
|
|
}
|
|
|
|
}
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2018-12-03 08:59:13 +01:00
|
|
|
index(req, res) {
|
|
|
|
res.json(api);
|
2017-09-07 21:42:21 +02:00
|
|
|
}
|
2018-11-24 12:58:30 +01:00
|
|
|
}
|
2016-11-09 22:31:49 +01:00
|
|
|
|
2018-11-24 12:58:30 +01:00
|
|
|
module.exports = IndexRouter;
|