1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01:00
unleash.unleash/src/lib/routes/admin-api/config.ts

39 lines
1.2 KiB
TypeScript
Raw Normal View History

import { Request, Response } from 'express';
import { IUnleashServices } from '../../types/services';
import { IUnleashConfig } from '../../types/option';
import version from '../../util/version';
2019-03-12 10:46:08 +01:00
const Controller = require('../controller');
class ConfigController extends Controller {
constructor(
config: IUnleashConfig,
{ versionService }: Pick<IUnleashServices, 'versionService'>,
) {
2019-03-12 10:46:08 +01:00
super(config);
this.versionService = versionService;
2021-04-15 11:35:45 +02:00
const authenticationType =
config.authentication && config.authentication.type;
this.uiConfig = {
...config.ui,
2021-04-15 11:29:53 +02:00
authenticationType,
unleashUrl: config.server.unleashUrl,
baseUriPath: config.server.baseUriPath,
version,
};
2019-03-12 10:46:08 +01:00
this.get('/', this.getUIConfig);
}
async getUIConfig(req: Request, res: Response): Promise<void> {
2019-03-12 10:46:08 +01:00
const config = this.uiConfig;
if (this.versionService) {
const versionInfo = this.versionService.getVersionInfo();
res.json({ ...config, versionInfo });
} else {
res.json(config);
}
2019-03-12 10:46:08 +01:00
}
}
export default ConfigController;
2019-03-12 10:46:08 +01:00
module.exports = ConfigController;