-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
31 lines (24 loc) · 928 Bytes
/
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
'use strict';
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use('/dist', express.static(path.join(__dirname, 'dist')));
app.use('/vendor', express.static(path.join(__dirname, 'node_modules')));
app.use('/public', express.static(path.join(__dirname, 'public')));
app.use('/api', require('./api'));
app.get('/', (req, res, next) => res.sendFile(path.join(__dirname, 'index.html')));
app.use((err, req, res, next) => {
res.status(err.status || 500).send(err.message || 'Something broke.');
});
const port = process.env.PORT || 3000;
const db = require('./db');
app.listen(port, () => {
db.sync()
.then(db.seed)
.then(console.log('Database synced and seeded.'))
.then(console.log(`Listening on port ${ port }.`))
});
module.exports = app;