1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/lib/routes/client-api/index.js
ivaosthu ccaab0c47b fix: LogProvider as option injected to unleash.
Instead of instructing users to do static calls
in to Unleash, she should instead be allwed to
specify the log provider as an option to Unleash.

This commit introduces the "getLogger" option,
a function responsible for creating a logger.
2020-02-20 08:34:24 +01:00

28 lines
789 B
JavaScript

'use strict';
const Controller = require('../controller');
const FeatureController = require('./feature.js');
const MetricsController = require('./metrics.js');
const RegisterController = require('./register.js');
const apiDef = require('./api-def.json');
class ClientApi extends Controller {
constructor(config) {
super();
const stores = config.stores;
const getLogger = config.getLogger;
this.get('/', this.index);
this.use('/features', new FeatureController(stores, getLogger).router);
this.use('/metrics', new MetricsController(stores, getLogger).router);
this.use('/register', new RegisterController(stores, getLogger).router);
}
index(req, res) {
res.json(apiDef);
}
}
module.exports = ClientApi;