-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (30 loc) · 962 Bytes
/
index.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
import express from 'express';
const app = express();
import mysql from 'mysql';
import cors from 'cors';
import config from './dbconfig.js'
app.use(cors());
import dislike from './rotues/dislike.js';
import like from './rotues/like.js';
import notice from './rotues/notice.js';
import reservation from './rotues/reservation.js';
app.use('/dislike', dislike);
app.use('/like', like);
app.use('/notice', notice);
app.use('/reservation', reservation);
app.get('/', function(req, res){
const db = mysql.createConnection(config);
db.query('Select Max(id) from notice', function(err, rows){
var max = rows[0];
res.json(max[Object.keys(max)[0]]);
})
db.end();
})
app.get('/pages', async(req, res) => {
let max = await getMax();
res.json(Math.ceil((max+1)/5));
})
const server = app.listen(process.env.PORT || 5000, () => {
const port = server.address().port;
console.log(`Express is working on port ${port}`);
});