forked from tricsi/upvote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (27 loc) · 824 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
/* eslint-disable no-console */
const express = require('express');
const cors = require('cors');
require('express-async-errors');
const model = require('./models');
const error = require('./middleware/error');
const app = express();
const port = process.env.PORT || 80;
app.set('model', model);
app.use(cors());
app.use(express.json());
app.use(express.static('dist'));
app.use('/auth', require('./routes/auth'));
app.use('/api/ping', require('./routes/ping'));
app.use('/api/entry', require('./routes/entry'));
app.use('/api/vote', require('./routes/vote'));
app.get('/*', (req, res) => {
res.sendFile(__dirname + '/dist/index.html');
});
app.use(error);
async function start() {
await model.sequelize.authenticate();
app.listen(port, () => {
console.log(`Server listening on port ${port}!`);
});
}
start();