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
61 lines
1.3 KiB
TypeScript
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',
|
|
};
|
|
}
|
|
}
|