-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (28 loc) · 858 Bytes
/
index.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
const express = require("express");
const app = express();
const dotenv = require("dotenv").config();
const Joi = require("joi");
const pug = require("pug");
const port = process.env.PORT || 3000;
const home = require("./routes/home");
const genres = require("./routes/genres");
const morgan = require("morgan");
const debugStart = require("debug")("app:startup");
if (app.get("env") === "development") {
app.use(morgan("tiny"));
debugStart("morgan pkg enabled");
}
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static("public"));
app.set("view engine", "pug");
app.use("/api/v1/genres", genres);
app.use("/", home);
//app.use("/", (req, res) => {
// console.log("Hello World");
//});
app.listen(port, () => {
debugStart(
`Server running: \n${process.env.NODE_ENV.toUpperCase()} (${port})`
);
});