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,15 +3,23 @@
const { Router } = require('express');
const { register: prometheusRegister } = require('prom-client');
exports.router = config => {
const router = Router();
class BackstageController {
constructor(config) {
const router = Router();
if (config.serverMetrics) {
router.get('/prometheus', (req, res) => {
res.set('Content-Type', prometheusRegister.contentType);
res.end(prometheusRegister.metrics());
});
if (config.serverMetrics) {
router.get('/prometheus', (req, res) => {
res.set('Content-Type', prometheusRegister.contentType);
res.end(prometheusRegister.metrics());
});
}
this.app = router;
}
return 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 HealthCheckController = require('./health-check');
const backstage = require('./backstage.js');
const BackstageController = require('./backstage.js');
exports.router = function(config) {
const router = 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) => {
res.json({