34 lines
848 B
TypeScript
34 lines
848 B
TypeScript
// server/api/health.get.ts
|
|
// Health check endpoint for Docker and monitoring
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
try {
|
|
// Basic health check
|
|
const health = {
|
|
status: 'healthy',
|
|
timestamp: new Date().toISOString(),
|
|
uptime: process.uptime(),
|
|
environment: process.env.NODE_ENV || 'development',
|
|
memory: {
|
|
used: Math.round(process.memoryUsage().heapUsed / 1024 / 1024),
|
|
total: Math.round(process.memoryUsage().heapTotal / 1024 / 1024),
|
|
unit: 'MB'
|
|
}
|
|
};
|
|
|
|
return {
|
|
success: true,
|
|
...health
|
|
};
|
|
} catch (error: any) {
|
|
// If health check fails, return 500
|
|
setResponseStatus(event, 500);
|
|
return {
|
|
success: false,
|
|
status: 'unhealthy',
|
|
error: error.message,
|
|
timestamp: new Date().toISOString()
|
|
};
|
|
}
|
|
});
|