-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
54 lines (40 loc) · 1.3 KB
/
server.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 app = express();
const port = 3000;
const bodyParser = require('body-parser');
const path = require('path');
const publicPath = path.join(__dirname,'image', 'public');
const cors = require('cors');
const productRouter = require('./routes/product');
const marketRouter = require('./routes/market');
const categoryRouter = require('./routes/category');
const basketRouter = require('./routes/basket');
const orderRouter = require('./routes/order');
const db = require('./db');
app.use(bodyParser.json());
app.use(express.static(publicPath));
db.connect();
let corsOptions = {
origin: ['*', 'null'],
credentials: true
}
app.use(cors(corsOptions));
app.use('/product',productRouter);
app.use('/market',marketRouter);
app.use('/category',categoryRouter);
app.use('/basket',basketRouter);
app.use('/order',orderRouter);
app.get('/', async (req, res) => {
res.header("Access-Control-Allow-Origin", "*");
return res.json({
success: true,
});
});
app.listen(port, () => {
console.log(`server is listening at localhost:${port}`);
})
//1시간 주기로 MySQL Connection 유지용 쿼리 보내기
const mysql_Connect_Maintenance = setInterval(() => {
const connection = db.return_connection();
connection.query("SELECT 1");
}, 360000); //10분