2019-03-12 10:46:08 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const Controller = require('../controller');
|
|
|
|
|
|
|
|
class ConfigController extends Controller {
|
2021-02-19 11:13:25 +01:00
|
|
|
constructor(config, { versionService }) {
|
2019-03-12 10:46:08 +01:00
|
|
|
super(config);
|
2021-02-19 11:13:25 +01:00
|
|
|
this.versionService = versionService;
|
|
|
|
this.uiConfig = {
|
|
|
|
...config.ui,
|
|
|
|
version: config.version,
|
|
|
|
};
|
2019-03-12 10:46:08 +01:00
|
|
|
this.get('/', this.getUIConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
async getUIConfig(req, res) {
|
|
|
|
const config = this.uiConfig;
|
2021-02-19 11:13:25 +01:00
|
|
|
if (this.versionService) {
|
|
|
|
const versionInfo = this.versionService.getVersionInfo();
|
|
|
|
res.json({ ...config, versionInfo });
|
|
|
|
} else {
|
|
|
|
res.json(config);
|
|
|
|
}
|
2019-03-12 10:46:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ConfigController;
|