Spaces:
Running
Running
Download src/controllers/health.controller.ts from its-seraj/auth-service: direct link, hf CLI and curl.
- Browser
- Download file 668 Bytes
-
https://huggingface.co/spaces/its-seraj/auth-service/resolve/main/src/controllers/health.controller.ts
- Command line
-
hf download hf://spaces/its-seraj/auth-service/src/controllers/health.controller.ts
-
curl -L -o health.controller.ts https://huggingface.co/spaces/its-seraj/auth-service/resolve/main/src/controllers/health.controller.ts
668 Bytes
| import { Request, Response } from 'express'; | |
| import { isDatabaseConnected } from '../config/database'; | |
| export const getHealth = (_req: Request, res: Response): void => { | |
| const dbConnected = isDatabaseConnected(); | |
| const healthData = { | |
| status: dbConnected ? 'ok' : 'degraded', | |
| timestamp: new Date().toISOString(), | |
| uptime: process.uptime(), | |
| memory: { | |
| heapUsedMb: Math.round((process.memoryUsage().heapUsed / 1024 / 1024) * 100) / 100, | |
| rssMb: Math.round((process.memoryUsage().rss / 1024 / 1024) * 100) / 100 | |
| }, | |
| database: dbConnected ? 'connected' : 'disconnected' | |
| }; | |
| res.status(dbConnected ? 200 : 503).json(healthData); | |
| }; | |