mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-04-11 18:08:16 +00:00
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { Controller, Get, Logger } from '@nestjs/common';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import axios from 'axios';
|
|
|
|
@Controller('api/health')
|
|
export class HealthController {
|
|
private readonly logger = new Logger(HealthController.name);
|
|
private readonly graphqlUrl: string;
|
|
|
|
constructor(private config: ConfigService) {
|
|
this.graphqlUrl = config.get<string>('platform.graphqlUrl')!;
|
|
}
|
|
|
|
@Get()
|
|
async check() {
|
|
let platformReachable = false;
|
|
let platformLatency = 0;
|
|
|
|
try {
|
|
const start = Date.now();
|
|
await axios.post(this.graphqlUrl, { query: '{ __typename }' }, {
|
|
headers: { 'Content-Type': 'application/json' },
|
|
timeout: 5000,
|
|
});
|
|
platformLatency = Date.now() - start;
|
|
platformReachable = true;
|
|
} catch {
|
|
platformReachable = false;
|
|
}
|
|
|
|
return {
|
|
status: platformReachable ? 'ok' : 'degraded',
|
|
platform: { reachable: platformReachable, latencyMs: platformLatency },
|
|
ozonetel: { configured: !!process.env.EXOTEL_API_KEY },
|
|
ai: { configured: !!process.env.ANTHROPIC_API_KEY },
|
|
};
|
|
}
|
|
}
|