mirror of
https://github.com/lucasrcsantana/story-generator.git
synced 2025-12-17 05:47:52 +00:00
- Implementa cliente Redis com retry e cache - Adiciona healthcheck da API - Configura tipagem para Next.js API routes - Implementa cache de histórias - Adiciona tratamento de erros robusto - Configura monitoramento de conexões - Otimiza performance com cache distribuído
22 lines
776 B
TypeScript
22 lines
776 B
TypeScript
import redis from '@/lib/redis';
|
|
import { supabase } from '@/lib/supabase';
|
|
|
|
export default async function handler(_: any, res: { status: (arg0: number) => { (): any; new(): any; json: { (arg0: { status: string; error?: any; }): void; new(): any; }; }; }) {
|
|
try {
|
|
// Verifica conexão com Redis
|
|
await redis.ping();
|
|
|
|
// Verifica conexão com Supabase
|
|
const { data, error } = await supabase.from('stories').select('id').limit(1);
|
|
|
|
if (error) throw error;
|
|
|
|
res.status(200).json({ status: 'healthy' });
|
|
} catch (error: unknown) {
|
|
if (error instanceof Error) {
|
|
res.status(500).json({ status: 'unhealthy', error: error.message });
|
|
} else {
|
|
res.status(500).json({ status: 'unhealthy', error: 'Erro desconhecido' });
|
|
}
|
|
}
|
|
} |