forked from danceoval/study-saturdays
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.js
31 lines (24 loc) · 767 Bytes
/
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
const express = require('express')
const app = express()
const bodyParser = require('body-parser')
const Student = require('./routes/student')
const Test = require('./routes/test')
const morgan = require('morgan')
const db = require('./db/db')
const path = require('path');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(morgan('dev'));
app.use('/student', Student)
app.use('/test', Test)
app.use(express.static(path.join(__dirname, 'public')));
app.use(function(err, req, res, next) {
console.error(err.stack);
res.status(500).send('Something broke!');
});
db.sync({force:true})
.then(() => app.listen(3000, function () {
console.log('Server is listening on port 3000!');
})
)
.catch(console.error);