forked from Techtonica/keyboard-shortcuts-practice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (26 loc) · 832 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 path = require("path");
const morgan = require("morgan");
const express = require("express");
const bodyParser = require("body-parser");
const { connectToDb } = require("./JS/orm");
const app = express();
app.use(morgan("dev")); //morgan gives us useful logging
require("ejs");
app.set("view engine", "ejs");
app.set("views", path.join(__dirname, "views"));
app.use(express.static("public"));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
const routes = require("./routes/routes.js");
app.use("/", routes);
app.use((req, res) => {
res.status(404).render("not_found");
});
const startServer = async () => {
await connectToDb();
const port = process.env.port || 3000;
app.listen(port, () => {
console.log(`Listening on http://localhost:${port} :-D`);
});
};
startServer();