feat: bootstrap from Fabric monorepo
This commit is contained in:
25
src/common/health.controller.ts
Normal file
25
src/common/health.controller.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Controller, Get, ServiceUnavailableException } from '@nestjs/common';
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
@Controller('healthz')
|
||||
export class HealthController {
|
||||
constructor(private readonly dataSource: DataSource) {}
|
||||
|
||||
@Get()
|
||||
async get() {
|
||||
try {
|
||||
await this.dataSource.query('SELECT 1');
|
||||
return {
|
||||
ok: true,
|
||||
service: 'center',
|
||||
database: 'ready',
|
||||
};
|
||||
} catch {
|
||||
throw new ServiceUnavailableException({
|
||||
ok: false,
|
||||
service: 'center',
|
||||
database: 'not_ready',
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user