issue # spring -> fastify 이전 중

This commit is contained in:
2025-11-13 05:42:22 +00:00
parent 8d0329187b
commit c72eca92f1
7 changed files with 73 additions and 3 deletions

17
src/app.ts Normal file
View File

@@ -0,0 +1,17 @@
import Fastify from 'fastify';
import fastifyPostgres from 'fastify-postgres';
import { registerSwagger } from './utils/plugin/swagger';
import dotenv from 'dotenv';
dotenv.config();
export async function buildApp() {
const app = Fastify();
await app.register(fastifyPostgres, {
connectionString: `postgresql://${process.env.PGUSER}:${process.env.PGPASSWORD}@${process.env.PGHOST}:${process.env.PGPORT}/${process.env.PGDATABASE}`
})
await registerSwagger(app);
return app;
}

0
src/route/user.route.ts Normal file
View File

View File

@@ -0,0 +1,14 @@
import { buildApp } from './app';
const start = async () => {
try {
const app = await buildApp();
await app.listen({ port: 3000 });
console.log(`Server running on port ${process.env.PORT}`);
} catch (err) {
console.error(err);
process.exit(1);
}
}
start();

View File

@@ -0,0 +1,33 @@
import { FastifyInstance } from "fastify";
import fastifySwagger from "@fastify/swagger";
import fastifySwaggerUi from "@fastify/swagger-ui";
export async function registerSwagger(fastify: FastifyInstance) {
await fastify.register(fastifySwagger, {
openapi: {
info: {
title: "API Docs",
description: "API documentation for Fastify server",
version: "1.0.0"
},
servers: [
{
url: "http://localhost:3000",
description: "Local Development",
},
{
url: "https://api.scheduler.bkdhome.p-e.kr",
description: "Production Server"
}
]
}
});
await fastify.register(fastifySwaggerUi, {
routePrefix: "/docs",
uiConfig: {
docExpansion: "none",
deepLinking: false
}
});
}