- watchdog.sh / deploy.sh / detect-node.sh repris de GoSortir : relance automatique si /api/health ne répond plus, déploiement par fichier DEPLOY avec retour arrière automatique, RESTART, ROLLBACK - /api/health et /api/health/ready (base de données) pour sonde externe - CORS appliqué aussi à /uploads (suggestion de couleur depuis l'admin) - admin/.env.production vers https://api.monespacepro.eu - docs/deploiement.md : guide CloudPanel complet Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
797 B
TypeScript
27 lines
797 B
TypeScript
import { Controller, Get, ServiceUnavailableException } from '@nestjs/common';
|
|
import { SkipThrottle } from '@nestjs/throttler';
|
|
import { PrismaService } from './prisma/prisma.service';
|
|
|
|
/** Sondes de santé : watchdog (cron) et surveillance externe (UptimeRobot…). */
|
|
@Controller('health')
|
|
@SkipThrottle()
|
|
export class HealthController {
|
|
constructor(private prisma: PrismaService) {}
|
|
|
|
/** Le process répond (utilisé par watchdog.sh). */
|
|
@Get()
|
|
check() {
|
|
return { status: 'ok' };
|
|
}
|
|
|
|
/** Le process ET la base répondent. */
|
|
@Get('ready')
|
|
async ready() {
|
|
try {
|
|
await this.prisma.$queryRaw`SELECT 1`;
|
|
return { status: 'ok', database: 'ok' };
|
|
} catch {
|
|
throw new ServiceUnavailableException({ status: 'error', database: 'unreachable' });
|
|
}
|
|
}
|
|
}
|