mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-31 13:47:02 +02:00
Add project-health.ts
This commit is contained in:
parent
cdac52a742
commit
de69622064
44
src/lib/routes/admin-api/project/project-health.ts
Normal file
44
src/lib/routes/admin-api/project/project-health.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { Request, Response } from 'express';
|
||||||
|
import Controller from '../../controller';
|
||||||
|
import { IUnleashServices } from '../../../types/services';
|
||||||
|
import { IUnleashConfig } from '../../../types/option';
|
||||||
|
import ProjectHealthService from '../../../services/project-health-service';
|
||||||
|
import { Logger } from '../../../logger';
|
||||||
|
import { IProjectParam } from '../../../types/model';
|
||||||
|
import { handleErrors } from '../util';
|
||||||
|
|
||||||
|
export default class ProjectHealthReport extends Controller {
|
||||||
|
private projectHealthService: ProjectHealthService;
|
||||||
|
|
||||||
|
private logger: Logger;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
config: IUnleashConfig,
|
||||||
|
{
|
||||||
|
projectHealthService,
|
||||||
|
}: Pick<IUnleashServices, 'projectHealthService'>,
|
||||||
|
) {
|
||||||
|
super(config);
|
||||||
|
this.logger = config.getLogger('/admin-api/project/health-report');
|
||||||
|
this.projectHealthService = projectHealthService;
|
||||||
|
this.get('/:projectId/health-report', this.getProjectHealthReport);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getProjectHealthReport(
|
||||||
|
req: Request<IProjectParam, any, any, any>,
|
||||||
|
res: Response,
|
||||||
|
): Promise<void> {
|
||||||
|
const { projectId } = req.params;
|
||||||
|
try {
|
||||||
|
const overview = await this.projectHealthService.getProjectHealthReport(
|
||||||
|
projectId,
|
||||||
|
);
|
||||||
|
res.json({
|
||||||
|
version: 2,
|
||||||
|
...overview,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
handleErrors(res, this.logger, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user