feat: add api foundation and booking schema

This commit is contained in:
2026-09-18 15:14:49 +08:00
parent 55b2b091c2
commit 5e71b89e95
8 changed files with 1556 additions and 31 deletions

View File

@@ -1,3 +1,35 @@
export function healthMessage(): string {
return "personal-brand-api";
import "reflect-metadata";
import { Controller, Get, Injectable, Module } from "@nestjs/common";
import { NestFactory } from "@nestjs/core";
import { FastifyAdapter } from "@nestjs/platform-fastify";
import type { NestFastifyApplication } from "@nestjs/platform-fastify";
import { PrismaClient } from "@prisma/client";
@Injectable()
export class PrismaService extends PrismaClient {
async onModuleDestroy(): Promise<void> {
await this.$disconnect();
}
}
@Controller("health")
export class HealthController {
@Get()
check(): { status: string; service: string } {
return { status: "ok", service: "personal-brand-api" };
}
}
@Module({ controllers: [HealthController], providers: [PrismaService], exports: [PrismaService] })
export class AppModule {}
export async function createApp(): Promise<NestFastifyApplication> {
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
app.enableCors();
return app;
}
if (process.env.NODE_ENV !== "test") {
const app = await createApp();
await app.listen({ port: Number(process.env.API_PORT ?? 3001), host: "0.0.0.0" });
}