-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
44 lines (38 loc) · 1.25 KB
/
server.js
File metadata and controls
44 lines (38 loc) · 1.25 KB
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
const express = require('express');
const app = express();
const cors = require('cors');
const { sequelize } = require('./models');
const propertyRouter = require('./routes/Properties');
const authRouter = require('./routes/Auth');
const swaggerUi = require('swagger-ui-express');
const swaggerJsdoc = require('swagger-jsdoc');
const options = {
definition: {
openapi: '3.0.0',
info: {
title: '부동산 매물 관리 시스템 API',
version: '1.0.0',
description: '매물 등록, 수정, 삭제(권한필요), 검색 기능을 제공합니다.',
},
},
//routes 폴더에 있는 모든 .js 파일의 주석(@swagger)을 읽어옴
apis: ['./routes/*.js'],
};
const swaggerSpec = swaggerJsdoc(options);
app.use(cors());
app.use(express.json());
// API 주소 연결
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
app.use('/api/properties', propertyRouter);
app.use('/api/auth', authRouter);
// 서버 실행
sequelize.sync({ force: false })
.then(() => {
console.log('데이터베이스 연결 성공 (SQLite)');
app.listen(3000, () => {
console.log('서버 실행 중: http://localhost:3000/api-docs (Swagger 확인)');
});
})
.catch((err) => {
console.error('DB 연결 에러:', err);
});