-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
54 lines (45 loc) · 1.26 KB
/
app.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
const express = require("express");
const cors = require("cors");
const { sequelize } = require("./models");
const cron = require('node-cron');
const { swaggerUi, specs } = require('./modules/swagger');
const app = express();
app.use(
cors({
origin: '*', //이거 env로 바꿔야됨 ㅋㅋ
credentials: true,
withCredentials: true,
optionsSuccessStatus: 200,
})
);
app.set("port", process.env.PORT);
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));
sequelize
.sync({ force: false })
.then(() => {
console.log("데이터베이스 연결됨.");
})
.catch((err) => {
console.error(err);
});
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
const loginRouter = require("./routes/loginRouter");
app.use("/login", loginRouter);
const teamRouter = require("./routes/teamRouter");
app.use("/team", teamRouter);
app.listen(app.get("port"), () => {
console.log(app.get("port"), "번 포트에서 대기 중");
});
app.get('/', (req, res) => {
res.send('BSSMBALL API (PORT : 9898)');
});
cron.schedule('0 0 * * *', () => {
Vote.destroy({ truncate: true }) // Vote 테이블 초기화
.then(() => {
console.log('Vote 테이블 초기화 완료');
})
.catch((err) => {
console.error(err);
});
});