-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
46 lines (35 loc) · 887 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 express = require("express");
const morgan = require("morgan");
//db
const app = express();
const { db, _Page, _User } = require('./models');
//views
const layoutFunc = require("./views/layout");
//middlewware
app.use(morgan('dev'));
app.use(express.static(__dirname + "/public"));
app.use(express.urlencoded({ extended: false }));
//Routing
const wikiRouter = require('./wiki/wiki');
const userRouter = require('./wiki/users');
app.use('/wiki', wikiRouter);
app.use('/users', userRouter);
//db connection confirmation console.log
db.authenticate()
.then(() => {
console.log('connected to the database');
})
//Get
app.get('/', (req, res) => {
res.redirect('/wiki')
})
//Port
const PORT = 3000;
//Sync
const init = async () => {
await db.sync({ force: false });
app.listen(PORT, () => {
console.log(`Server is listning on port ${PORT}!`)
})
}
init();