-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
31 lines (31 loc) · 1.23 KB
/
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
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.app = void 0;
const dotenv_1 = require("dotenv");
if (process.env.NODE_ENV !== "production") {
dotenv_1.config();
}
const express_1 = __importDefault(require("express"));
const express_handlebars_1 = __importDefault(require("express-handlebars"));
const path_1 = __importDefault(require("path"));
const index_1 = require("./routes/index");
const compression_1 = __importDefault(require("compression"));
const app = express_1.default();
exports.app = app;
app.use(compression_1.default());
app.use(express_1.default.urlencoded({ extended: false }));
app.use(express_1.default.json());
app.use(express_1.default.static(path_1.default.join(__dirname, "public")));
app.engine("hbs", express_handlebars_1.default({ defaultLayout: "main", extname: "hbs" }));
app.set("view engine", "hbs");
app.use("/", index_1.indexRouter);
app.use((req, res, next) => {
res.render("pages/404", { page_name: "Page Not found" });
});
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});