25 lines
579 B
TypeScript
25 lines
579 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { DataSource } from 'typeorm';
|
|
import { API_PHASE, API_VERSION } from './version';
|
|
|
|
@Injectable()
|
|
export class HealthService {
|
|
constructor(private readonly dataSource: DataSource) {}
|
|
|
|
async check() {
|
|
const startedAt = Date.now();
|
|
await this.dataSource.query('SELECT 1');
|
|
|
|
return {
|
|
status: 'ok',
|
|
service: 'dhv2-api',
|
|
api: 'v3',
|
|
version: API_VERSION,
|
|
phase: API_PHASE,
|
|
database: 'ok',
|
|
time: new Date().toISOString(),
|
|
latencyMs: Date.now() - startedAt,
|
|
};
|
|
}
|
|
}
|