Skip to content

Commit efff500

Browse files
committed
feat: added app controller for health check
1 parent ff43633 commit efff500

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/app.controller.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Test, TestingModule } from '@nestjs/testing';
2+
import { AppController } from './app.controller';
3+
4+
describe('AppController', () => {
5+
let app: TestingModule;
6+
7+
beforeAll(async () => {
8+
app = await Test.createTestingModule({
9+
controllers: [AppController],
10+
}).compile();
11+
});
12+
13+
describe('healthCheck', () => {
14+
it('should return the health check info', () => {
15+
const appController = app.get<AppController>(AppController);
16+
expect(appController.healthCheck()).toStrictEqual({
17+
message:'Service is alive',
18+
status: 200,
19+
});
20+
});
21+
});
22+
});

src/app.controller.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Controller, Get } from '@nestjs/common';
2+
3+
@Controller()
4+
export class AppController {
5+
@Get('/health')
6+
healthCheck() {
7+
return {
8+
message: 'Service is alive',
9+
status: 200,
10+
};
11+
}
12+
}

0 commit comments

Comments
 (0)