26 lines
569 B
TypeScript
26 lines
569 B
TypeScript
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',
|
|
});
|
|
}
|
|
}
|
|
}
|