-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (28 loc) · 820 Bytes
/
app.js
File metadata and controls
34 lines (28 loc) · 820 Bytes
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
const morgan = require("morgan");
const express = require("express");
const wiki = require("./routes/wiki");
const html = require("./views/layout");
const users = require("./routes/users");
const { db, Page, User } = require("./models");
const port = 3000;
const app = express();
app.use(express.urlencoded({ extended: false }));
app.use(morgan("dev"));
app.use(express.static("./public"));
app.use("/wiki", wiki);
app.use("/users", users);
db.authenticate().then(() => {
console.log("connected to the database. Hooray!");
});
async function dbSync() {
// await Page.sync({ force: true });
// await User.sync({ force: true });
await db.sync();
}
app.get("/", (req, res) => {
res.send(html());
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});
dbSync();