-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (30 loc) · 843 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
32
33
34
35
36
37
38
const express = require('express');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const app = express();
const layout = require('./views/layout');
const { db } = require('./models');
const models = require('./models');
app.use(morgan('dev'));
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.urlencoded({extended: false}));
app.use('/wiki', require('./routes/wiki'));
app.use('/users', require('./routes/user'));
app.get('/', (req, res, next) => {
try {
res.redirect('/wiki');
} catch (next) {
next (error)
}
});
db.authenticate().
then(() => {
console.log('connected to the database');
});
const init = async() => {
await models.db.sync({force: true});
app.listen(3000, () => {
console.log(`App listening in port 3000`);
});
};
init();