Skip to content

Commit

Permalink
Add some swagger decorators to health check route
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejkang committed Aug 21, 2021
1 parent 055e0f3 commit 9605487
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import { Controller, Get } from '@nestjs/common';
import { Controller, Get, HttpCode } from '@nestjs/common';
import { ApiOperation, ApiProperty, ApiResponse, ApiTags } from '@nestjs/swagger';
import { AppService } from './app.service';

interface IHealthCheckResult {
ok: boolean;
}

class HealthCheckResponse {
@ApiProperty({
description: 'Health Check Result',
})
ok: boolean;
}

@ApiTags('Health Check')
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}

@Get()
@HttpCode(200)
@ApiOperation({ summary: 'Health check' })
@ApiResponse({ status: 200, description: 'Response Successfully', type: HealthCheckResponse })
getHealthCheck(): IHealthCheckResult {
return {
ok: this.appService.getOk(),
};
}
}

interface IHealthCheckResult {
ok: boolean;
}

0 comments on commit 9605487

Please sign in to comment.