2021-04-22 10:07:10 +02:00
|
|
|
import { Request, Response } from 'express';
|
2021-03-11 22:51:58 +01:00
|
|
|
import { BackstageController } from './backstage';
|
2021-04-16 15:29:23 +02:00
|
|
|
import ResetPasswordController from './auth/reset-password-controller';
|
2022-01-28 12:50:35 +01:00
|
|
|
import SimplePasswordProvider from './auth/simple-password-provider';
|
2021-04-22 10:07:10 +02:00
|
|
|
import { IUnleashConfig } from '../types/option';
|
|
|
|
import { IUnleashServices } from '../types/services';
|
2021-09-14 20:07:05 +02:00
|
|
|
import { api } from './api-def';
|
2022-06-03 11:50:58 +02:00
|
|
|
import LogoutController from './logout';
|
2016-06-18 21:53:18 +02:00
|
|
|
|
2018-11-29 21:25:45 +01:00
|
|
|
const AdminApi = require('./admin-api');
|
2018-11-24 15:45:22 +01:00
|
|
|
const ClientApi = require('./client-api');
|
2018-12-03 08:59:13 +01:00
|
|
|
const Controller = require('./controller');
|
2018-11-24 12:43:46 +01:00
|
|
|
const HealthCheckController = require('./health-check');
|
2018-12-03 08:59:13 +01:00
|
|
|
class IndexRouter extends Controller {
|
2021-04-22 10:07:10 +02:00
|
|
|
constructor(config: IUnleashConfig, services: IUnleashServices) {
|
2021-03-11 22:51:58 +01:00
|
|
|
super(config);
|
2021-04-22 10:07:10 +02:00
|
|
|
this.use('/health', new HealthCheckController(config, services).router);
|
2021-02-16 14:30:08 +01:00
|
|
|
this.use('/internal-backstage', new BackstageController(config).router);
|
2020-03-29 22:22:19 +02:00
|
|
|
this.use('/logout', new LogoutController(config).router);
|
2021-04-09 13:46:53 +02:00
|
|
|
this.use(
|
|
|
|
'/auth/simple',
|
|
|
|
new SimplePasswordProvider(config, services).router,
|
|
|
|
);
|
2021-04-16 15:29:23 +02:00
|
|
|
this.use(
|
|
|
|
'/auth/reset',
|
|
|
|
new ResetPasswordController(config, services).router,
|
|
|
|
);
|
2018-12-03 08:59:13 +01:00
|
|
|
this.get(api.uri, this.index);
|
2020-12-17 19:43:01 +01:00
|
|
|
this.use(api.links.admin.uri, new AdminApi(config, services).router);
|
|
|
|
this.use(api.links.client.uri, new ClientApi(config, services).router);
|
2018-11-24 12:58:30 +01:00
|
|
|
}
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2021-04-22 10:07:10 +02:00
|
|
|
async index(req: Request, res: Response): Promise<void> {
|
2018-12-03 08:59:13 +01:00
|
|
|
res.json(api);
|
2017-09-07 21:42:21 +02:00
|
|
|
}
|
2018-11-24 12:58:30 +01:00
|
|
|
}
|
2016-11-09 22:31:49 +01:00
|
|
|
|
2021-04-22 10:07:10 +02:00
|
|
|
export default IndexRouter;
|
|
|
|
|
2018-11-24 12:58:30 +01:00
|
|
|
module.exports = IndexRouter;
|