xpeditis2.0/apps/backend/src/application/controllers/health.controller.ts
David-Henri ARNAUD e863399bb2
Some checks failed
CI / Lint & Format Check (push) Failing after 1m11s
CI / Test Backend (push) Failing after 1m32s
CI / Build Backend (push) Has been skipped
Security Audit / npm audit (push) Failing after 5s
Security Audit / Dependency Review (push) Has been skipped
CI / Test Frontend (push) Failing after 29s
CI / Build Frontend (push) Has been skipped
first commit
2025-10-07 18:39:32 +02:00

61 lines
1.3 KiB
TypeScript

import { Controller, Get } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
@ApiTags('health')
@Controller('health')
export class HealthController {
@Get()
@ApiOperation({ summary: 'Health check endpoint' })
@ApiResponse({
status: 200,
description: 'Service is healthy',
schema: {
example: {
status: 'ok',
timestamp: '2024-01-01T00:00:00.000Z',
uptime: 12345.67,
environment: 'development',
version: '0.1.0',
},
},
})
check() {
return {
status: 'ok',
timestamp: new Date().toISOString(),
uptime: process.uptime(),
environment: process.env.NODE_ENV || 'development',
version: '0.1.0',
};
}
@Get('ready')
@ApiOperation({ summary: 'Readiness check endpoint' })
@ApiResponse({
status: 200,
description: 'Service is ready to accept traffic',
})
ready() {
// Add checks for database, Redis, etc.
return {
status: 'ready',
checks: {
database: 'ok',
redis: 'ok',
},
};
}
@Get('live')
@ApiOperation({ summary: 'Liveness check endpoint' })
@ApiResponse({
status: 200,
description: 'Service is alive',
})
live() {
return {
status: 'alive',
};
}
}