2016-06-18 21:53:18 +02:00
|
|
|
'use strict';
|
|
|
|
|
2017-06-28 10:20:22 +02:00
|
|
|
const { Router } = require('express');
|
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-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-11-24 12:58:30 +01:00
|
|
|
class IndexRouter {
|
|
|
|
constructor(config) {
|
|
|
|
const router = Router();
|
|
|
|
this._router = router;
|
|
|
|
|
|
|
|
router.use('/health', new HealthCheckController(config).router());
|
2018-11-29 21:25:45 +01:00
|
|
|
router.use('/internal-backstage', new BackstageCTR(config).router());
|
|
|
|
router.get(api.uri, (req, res) => res.json(api));
|
|
|
|
router.use(api.links.admin.uri, new AdminApi(config).router());
|
|
|
|
router.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-11-29 21:01:53 +01:00
|
|
|
router.use(
|
|
|
|
'/api/features',
|
|
|
|
new FeatureController(config.stores).router()
|
|
|
|
);
|
2018-11-24 12:58:30 +01:00
|
|
|
}
|
|
|
|
}
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2018-11-24 12:58:30 +01:00
|
|
|
router() {
|
|
|
|
return this._router;
|
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;
|