forked from lucaslevin1/wikistack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (31 loc) · 1.05 KB
/
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
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 userRouter = require("./routes/user.js")
// const user = require('./routes/user.js');
db.authenticate().
then(() => {
console.log('connected to the database');
})
app.use(morgan('dev'));
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.urlencoded({extended: false}))
app.use('/wiki', wikiRouter);
app.use('/users', userRouter);
// app.use('/user', userRouter);
//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();