Files
hasher/app/api/health/route.ts
2025-12-15 17:43:08 +01:00

35 líneas
808 B
TypeScript

import { NextResponse } from 'next/server';
import { getRedisInfo, getStats, INDEX_NAME } from '@/lib/redis';
export async function GET() {
try {
// Check Redis connection and get info
const redisInfo = await getRedisInfo();
// Get stats
const stats = await getStats();
return NextResponse.json({
status: 'ok',
redis: {
version: redisInfo.version,
memory: redisInfo.memory,
dbSize: redisInfo.dbSize
},
stats: {
count: stats.count,
size: stats.size
}
});
} catch (error) {
console.error('Health check error:', error);
return NextResponse.json(
{
status: 'error',
error: error instanceof Error ? error.message : 'Unknown error'
},
{ status: 503 }
);
}
}