feat: add api foundation and booking schema
This commit is contained in:
@@ -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" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user