-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi.js
More file actions
46 lines (41 loc) · 1.31 KB
/
api.js
File metadata and controls
46 lines (41 loc) · 1.31 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
45
46
const express = require('express');
const cors = require('cors');
const controllers = require('./src/controllers');
require('dotenv').config(); // 환경 변수 로드
module.exports = class API {
constructor() {
this.app = express();
this.app.use(
cors({
origin: [
'http://localhost:3000',
'https://stretching-frontend.web.app',
],
}),
);
this.app.use(express.json());
}
setController() {
this.app.use('/api/v1/spots', controllers.v1.SpotController);
this.app.use('/api/v1/users', controllers.v1.UserController);
this.app.use('/api/v1/diary', controllers.v1.DiaryController);
this.app.use('/api/v1/survey', controllers.v1.SurveyController);
this.app.use('/api/v1/userfcmtoken', controllers.v1.UserFCMTokenController);
this.app.use('/api/v1/stress', controllers.v1.StressController);
this.app.use('/api/v1/surveyscore', controllers.v1.SurveyScoreController);
this.app.use('/api/v1/today', controllers.v1.TodayDiaryKeywordController);
}
listen() {
const PORT = 3000;
this.server = this.app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});
}
async close() {
return new Promise((resolve) => {
this.server.close(() => {
resolve();
});
});
}
};