-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
33 lines (26 loc) · 767 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
const express = require("express");
const app = express();
const morgan = require("morgan");
const { db, Page, User } = require("./models");
const path = require("path");
app.use(express.static(path.join(__dirname, "./public")));
app.use(morgan("dev"));
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.use("/wiki", require("./routes/wiki"));
//app.use("/wiki", require("./routes/users"));
app.get("/", (req, res, next) => {
res.redirect("/wiki/");
});
const PORT = 3000;
const init = async () => {
await db.sync({ force: true });
app.listen(PORT, () => {
console.log(`App listening in port ${PORT}`);
});
};
init();
db.authenticate().then(() => {
console.log("connected to the database");
});
module.exports = app;