1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01:00

chore(modernize): Modernize BackstageController

This commit is contained in:
ivaosthu 2018-11-24 12:48:19 +01:00 committed by Ivar Conradi Østhus
parent 7bc8ed0334
commit 6a36f71a98
2 changed files with 19 additions and 11 deletions

View File

@ -3,7 +3,8 @@
const { Router } = require('express'); const { Router } = require('express');
const { register: prometheusRegister } = require('prom-client'); const { register: prometheusRegister } = require('prom-client');
exports.router = config => { class BackstageController {
constructor(config) {
const router = Router(); const router = Router();
if (config.serverMetrics) { if (config.serverMetrics) {
@ -13,5 +14,12 @@ exports.router = config => {
}); });
} }
return router; this.app = router;
}; }
router() {
return this.app;
}
}
module.exports = BackstageController;

View File

@ -11,13 +11,13 @@ const clientApi = require('./client-api');
const clientFeatures = require('./client-api/feature.js'); const clientFeatures = require('./client-api/feature.js');
const HealthCheckController = require('./health-check'); const HealthCheckController = require('./health-check');
const backstage = require('./backstage.js'); const BackstageController = require('./backstage.js');
exports.router = function(config) { exports.router = function(config) {
const router = Router(); const router = Router();
router.use('/health', new HealthCheckController(config).router()); router.use('/health', new HealthCheckController(config).router());
router.use('/internal-backstage', backstage.router(config)); router.use('/internal-backstage', new BackstageController(config).router());
router.get('/api', (req, res) => { router.get('/api', (req, res) => {
res.json({ res.json({