2017-06-28 10:20:22 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { Router } = require('express');
|
2018-11-24 15:02:31 +01:00
|
|
|
const FeatureController = require('./feature.js');
|
2018-11-29 20:46:24 +01:00
|
|
|
const MetricsController = require('./metrics.js');
|
|
|
|
const RegisterController = require('./register.js');
|
|
|
|
const clientApiSpec = require('./client-api.json');
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2018-11-24 15:45:22 +01:00
|
|
|
class ClientApi {
|
|
|
|
constructor(config) {
|
|
|
|
const router = Router();
|
|
|
|
this._router = router;
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2018-11-24 15:45:22 +01:00
|
|
|
router.get('/', this.index);
|
|
|
|
router.use('/features', new FeatureController(config).router());
|
2018-11-29 20:46:24 +01:00
|
|
|
router.use('/metrics', new MetricsController(config).router());
|
|
|
|
router.use('/register', new RegisterController(config).router());
|
2018-11-24 15:45:22 +01:00
|
|
|
}
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2018-11-24 15:45:22 +01:00
|
|
|
index(req, res) {
|
2018-11-29 20:46:24 +01:00
|
|
|
res.json(clientApiSpec);
|
2018-11-24 15:45:22 +01:00
|
|
|
}
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2018-11-24 15:45:22 +01:00
|
|
|
router() {
|
|
|
|
return this._router;
|
|
|
|
}
|
|
|
|
}
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2018-11-29 20:46:24 +01:00
|
|
|
ClientApi.api = clientApiSpec;
|
2018-11-24 15:45:22 +01:00
|
|
|
|
|
|
|
module.exports = ClientApi;
|