diff --git a/backend/src/health.controller.ts b/backend/src/health.controller.ts new file mode 100644 index 0000000..adadf64 --- /dev/null +++ b/backend/src/health.controller.ts @@ -0,0 +1,28 @@ +import { Controller, Get } from "@nestjs/common"; +import { sql } from "drizzle-orm"; +import { DatabaseService } from "./database/database.service"; + +@Controller("health") +export class HealthController { + constructor(private readonly databaseService: DatabaseService) {} + + @Get() + async check() { + try { + // Check database connection + await this.databaseService.db.execute(sql`SELECT 1`); + return { + status: "ok", + database: "connected", + timestamp: new Date().toISOString(), + }; + } catch (error) { + return { + status: "error", + database: "disconnected", + message: error.message, + timestamp: new Date().toISOString(), + }; + } + } +}