-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
46 lines (35 loc) · 1017 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
42
43
44
45
46
const morgan = require('morgan');
const express = require('express');
const layout = require('./views/layout');
const models = require('./models');
const { db } = require('./models');
const wikiRouter = require('./routes/wiki');
const userRouter = require('./routes/user');
const app = express();
app.use(express.static(__dirname + '/public'));
app.use(morgan('dev'));
app.use(express.urlencoded({ extended: false }));
app.use('/wiki', wikiRouter);
// app.get('/', (req, res) => {
// res.send(layout());
// });
app.get('/', (req, res, next) => {
res.redirect('/wiki');
});
db.authenticate().then(() => {
console.log('connected to the database');
});
const PORT = 3000;
// app.listen(PORT, () => {
// console.log(`App listening in port ${PORT}`);
// });
const init = async () => {
// await models.User.sync();
// await models.Page.sync();
await models.db.sync();
//models.db.sync({force:})
app.listen(PORT, () => {
console.log(`Server is listening on port ${PORT}!`);
});
};
init();