feat: initial commit - Moraworld Imports project
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { HealthController } from "./health.controller";
|
||||
|
||||
@Module({
|
||||
controllers: [HealthController],
|
||||
})
|
||||
export class HealthModule {}
|
||||
Reference in New Issue
Block a user