issue # spring -> fastify 이전 중
This commit is contained in:
@@ -26,4 +26,5 @@ build: # This job runs in the build stage, which runs first.
|
|||||||
before_script:
|
before_script:
|
||||||
script:
|
script:
|
||||||
- echo "Compiling the code..."
|
- echo "Compiling the code..."
|
||||||
|
- npm run build
|
||||||
- echo "Compile complete."
|
- echo "Compile complete."
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"description": "",
|
"description": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@fastify/swagger": "^9.6.1",
|
||||||
|
"@fastify/swagger-ui": "^5.2.3",
|
||||||
"dotenv": "^17.2.3",
|
"dotenv": "^17.2.3",
|
||||||
"fastify": "^5.6.2",
|
"fastify": "^5.6.2",
|
||||||
"fastify-postgres": "^3.6.0",
|
"fastify-postgres": "^3.6.0",
|
||||||
|
|||||||
17
src/app.ts
Normal file
17
src/app.ts
Normal 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
0
src/route/user.route.ts
Normal 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();
|
||||||
33
src/utils/plugin/swagger.ts
Normal file
33
src/utils/plugin/swagger.ts
Normal 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
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,14 +1,17 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
"module": "CommonJS",
|
|
||||||
"lib": ["ESNext"],
|
"lib": ["ESNext"],
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"forceConsistentCasingInFileNames": true
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
},
|
},
|
||||||
"include": ["src/**/*"]
|
"include": ["src/**/*"],
|
||||||
|
"exclude": ["node_modules", "dist"]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user