-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
42 lines (31 loc) · 982 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
39
40
41
const express = require('express');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const path = require('path');
const layout = require('./views/layout');
const { db } = require('./models');
const wikiRouter = require('./routes/wiki');
const userRouter = require('./routes/user');
// const models = require('./models'); //is there a way to combine line 6 & 7?
const app = express();
app.use(morgan('dev'));
app.use(express.static(path.join(__dirname, './public')));
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.use('/wiki', wikiRouter);
app.get('/', (req, res, next) => {
res.redirect('/wiki');
})
// app.get('/', (req, res, next) => {
// res.send(layout(''));
// });
const init = async () => {
// await models.db.sync(); //same as below
await db.sync();
const port = 3000;
app.listen(port, () => {
console.log(`server listening on port ${port}`);
});
};
init();
module.exports = app;