-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswaggerConfig.js
55 lines (51 loc) · 1.42 KB
/
swaggerConfig.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import path, { dirname } from 'path';
import swaggerJSDoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const options = {
definition: {
openapi: '3.0.0',
info: {
title: 'Life Designer',
version: '1.0.0',
description: 'API documentation for Life Designer',
},
servers: [
{
url: 'http://localhost:3000', // 서버 주소
description: 'Local development server',
},
{
url: 'http://43.202.173.71:3000', // 프로덕션 서버 주소
description: 'Production server',
},
],
components: {
securitySchemes: {
bearerAuth: {
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT', // JWT 형식 사용
},
},
},
security: [
{
bearerAuth: [], // 모든 엔드포인트에 기본적으로 적용
},
],
},
apis: [
path.join(__dirname, './swagger/authentication.js'),
path.join(__dirname, './swagger/users.js'),
path.join(__dirname, './swagger/routines.js'),
path.join(__dirname, './swagger/subRoutines.js'),
path.join(__dirname, './swagger/statistics.js'),
],
};
const swaggerSpec = swaggerJSDoc(options);
export default (app) => {
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
};