MCPcopy Create free account
hub / github.com/Writesonic/GPTRouter / triggerHealthCheck

Function triggerHealthCheck

src/controllers/healthCheck.controller.ts:20–37  ·  view source on GitHub ↗
(
  request: FastifyRequestTypebox<typeof HealthCheckSchema>,
  reply: FastifyReplyTypebox<typeof HealthCheckSchema>,
)

Source from the content-addressed store, hash-verified

18 * @returns {Promise<import('../models/ModelHealthCheck')[]>} - The health check data from the database
19 */
20export const triggerHealthCheck = async (
21 request: FastifyRequestTypebox<typeof HealthCheckSchema>,
22 reply: FastifyReplyTypebox<typeof HealthCheckSchema>,
23) => {
24 try {
25 const promises = [
26 checkOpenaiHealth(request.server.orm),
27 checkChatOpenaiHealth(request.server.orm),
28 checkAnthropicHealth(request.server.orm),
29 checkCohereHealth(request.server.orm),
30 ];
31 await Promise.all(promises);
32 return await request.server.orm.getRepository(ModelHealthCheck).find();
33 } catch (e: any) {
34 Sentry.captureException(e);
35 reply.code(500).send(e);
36 }
37};
38
39/**
40 * Get health check data within a specific date range

Callers

nothing calls this directly

Calls 3

checkAnthropicHealthFunction · 0.85
checkCohereHealthFunction · 0.85
checkOpenaiHealthFunction · 0.50

Tested by

no test coverage detected