-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
36 lines (29 loc) · 989 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
const express = require('express');
const { db, Page, User } = require('./models');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const app = express();
const layout = require('./views/layout.js');
const wikiRouter = require('./routes/wiki.js');
// const user = require('./routes/user.js');
app.use(morgan('dev'));
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.urlencoded({extended: false}))
app.use('/wiki', wikiRouter);
// app.use('/user', userRouter);
db.authenticate().
then(() => {
console.log('connected to the database');
})
//this redirects to /wiki - provided by FS
app.get('/', (req, res, next) => {
res.redirect('/wiki');
})
const PORT = 3000;
const dbSync = async () =>{
await db.sync({force:true}); // // this drops all tables then recreates them based on our JS definitions // used for dev mode, not for production
app.listen(PORT, () => {
console.log(`App listening in port ${PORT}`);
});
}
dbSync();