Spaces:
Sleeping
Sleeping
Download src/controllers/health.controller.ts from sardarbipul/test: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/spaces/sardarbipul/test/resolve/main/src/controllers/health.controller.ts
- Command line
-
hf download hf://spaces/sardarbipul/test/src/controllers/health.controller.ts
-
curl -L -o health.controller.ts https://huggingface.co/spaces/sardarbipul/test/resolve/main/src/controllers/health.controller.ts
1.23 kB
| import { Request, Response } from 'express'; | |
| import { IDatasetService } from '../services/interfaces/IDatasetService'; | |
| export class HealthController { | |
| private datasetService: IDatasetService; | |
| constructor(datasetService: IDatasetService) { | |
| this.datasetService = datasetService; | |
| } | |
| public getHealth = async (req: Request, res: Response): Promise<void> => { | |
| try { | |
| const stats = await this.datasetService.getDatasetStats(); | |
| const memoryUsage = process.memoryUsage(); | |
| res.status(200).json({ | |
| status: 'healthy', | |
| timestamp: new Date().toISOString(), | |
| nodeVersion: process.version, | |
| uptimeSeconds: Math.floor(process.uptime()), | |
| memory: { | |
| rssMb: Math.round(memoryUsage.rss / (1024 * 1024)), | |
| heapTotalMb: Math.round(memoryUsage.heapTotal / (1024 * 1024)), | |
| heapUsedMb: Math.round(memoryUsage.heapUsed / (1024 * 1024)), | |
| }, | |
| storage: { | |
| csvAvailable: stats.csvExists, | |
| idxAvailable: stats.idxExists, | |
| totalIndexedRows: stats.totalIndexedRows, | |
| }, | |
| }); | |
| } catch (err: any) { | |
| res.status(500).json({ | |
| status: 'unhealthy', | |
| error: err.message, | |
| }); | |
| } | |
| }; | |
| } | |