|
1 | 1 | import {BaseHttpController, controller, httpGet} from "inversify-express-utils";
|
| 2 | +import * as swaggerUi from "swagger-ui-express"; |
2 | 3 |
|
| 4 | +import {getSwaggerSpecification} from "../../../infrastructure/utils/swagger-specification"; |
3 | 5 | import {HealthService} from "../../../services/health-service/health-service";
|
4 | 6 |
|
| 7 | +import {HttpMethodSync} from "./types"; |
| 8 | + |
5 | 9 | @controller("/Application")
|
6 | 10 | export class ApplicationController extends BaseHttpController {
|
7 | 11 | constructor(private readonly healthService: HealthService) {
|
8 | 12 | super();
|
9 | 13 | }
|
10 | 14 |
|
| 15 | + /** |
| 16 | + * @swagger |
| 17 | + * /Application/Health: |
| 18 | + * get: |
| 19 | + * tags: |
| 20 | + * - Application |
| 21 | + * summary: "Application Health" |
| 22 | + * description: "Returns general information regarding application health" |
| 23 | + * operationId: "applicationHealth" |
| 24 | + * responses: |
| 25 | + * 200: |
| 26 | + * description: "Health details retrieved" |
| 27 | + * content: |
| 28 | + * application/json: |
| 29 | + * schema: |
| 30 | + * $ref: '#/components/schemas/ApplicationHealthDto' |
| 31 | + */ |
11 | 32 | @httpGet("/Health")
|
12 |
| - public async getStatus() { |
| 33 | + public async getHealth() { |
13 | 34 | return this.healthService.getHealth();
|
14 | 35 | }
|
| 36 | + |
| 37 | + /** |
| 38 | + * @swagger |
| 39 | + * /Application/Docs: |
| 40 | + * get: |
| 41 | + * tags: |
| 42 | + * - Application |
| 43 | + * summary: "Application Swagger Documentation" |
| 44 | + * description: "Returns Swagger UI" |
| 45 | + * operationId: "applicationDocs" |
| 46 | + * responses: |
| 47 | + * 200: |
| 48 | + * description: "Swagger UI" |
| 49 | + */ |
| 50 | + @httpGet("/Docs") |
| 51 | + public async getApiDocumentation() { |
| 52 | + const swaggerSpecification = await getSwaggerSpecification(); |
| 53 | + const setup = swaggerUi.setup(swaggerSpecification, {explorer: true}) as HttpMethodSync; |
| 54 | + setup(this.httpContext.request, this.httpContext.response); |
| 55 | + } |
15 | 56 | }
|
0 commit comments