forked from emeshnick/wikistack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
46 lines (32 loc) · 847 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 app = express();
const bodyParser = require("body-parser");
const morgan = require("morgan");
const path = require("path");
const layout = require("./views/layout");
const { db, Page, User } = require("./models");
const wiki = require("./routes/wiki");
const users = require("./routes/users");
db.authenticate().then(() => {
console.log("connected to the database");
});
app.use(
bodyParser.urlencoded({
extended: false,
})
);
app.use(morgan("dev"));
app.use("/wiki", wiki);
app.use("/users", users);
app.get("/", (req, res) => {
res.send(layout());
});
app.use(express.static(path.join(__dirname, "public")));
async function syncDb() {
await db.sync({ force: true });
}
syncDb();
const PORT = 3000;
app.listen(PORT, () => {
console.log(`App listening in port ${PORT}`);
});