28 lines
620 B
TypeScript
28 lines
620 B
TypeScript
import { Controller, Get } from "@nestjs/common";
|
|
import { PrismaService } from "../prisma/prisma.service";
|
|
|
|
@Controller()
|
|
export class HealthController {
|
|
constructor(private readonly prisma: PrismaService) {}
|
|
|
|
@Get("health")
|
|
async health() {
|
|
let database: "ok" | "error" = "ok";
|
|
try {
|
|
await this.prisma.client.$queryRaw`SELECT 1`;
|
|
} catch {
|
|
database = "error";
|
|
}
|
|
|
|
return {
|
|
status: database === "ok" ? "ok" : "degraded",
|
|
service: "moraworld-api",
|
|
version: "0.1.0",
|
|
timestamp: new Date().toISOString(),
|
|
checks: {
|
|
database,
|
|
},
|
|
};
|
|
}
|
|
}
|