-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
61 lines (55 loc) · 2.27 KB
/
app.js
File metadata and controls
61 lines (55 loc) · 2.27 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Konstruct 2018: Official Technical Fest of Maulana Abul Kalam Azad
* University of Technology, West Bengal
* Copyright (C) 2018 Bytes Club <bytes-club@googlegroups.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Import node packages
const express = require("express"),
bodyParser = require("body-parser"),
errorHandler = require("errorhandler"),
methodOverride = require("method-override"),
morgan = require("morgan"),
path = require("path"),
stylus = require("stylus");
// Create Express Application
const App = express();
// All environments for Application
App.set("env", process.env.NODEJS_ENV);
App.set("host", process.env.NODEJS_IP || "127.0.0.1");
App.set("port", process.env.NODEJS_PORT || 8080);
App.use(bodyParser.json());
App.use(bodyParser.urlencoded({ extended: false }));
App.use(methodOverride());
App.set("views", path.join(__dirname, "Views"));
App.set("view engine", "pug");
App.use(stylus.middleware(path.join(__dirname, "Static")));
App.use(express.static(path.join(__dirname, "Static")));
App.set("x-powered-by", false);
// Debug log in Development
if (App.get("env") === "development") {
App.use(errorHandler());
App.use(morgan("[:date[clf]] :remote-addr :remote-user :method :url HTTP/:http-version :status - :response-time ms"));
App.locals.pretty = true;
}
// Default handler
App.get("/", function (req, res) {
res.send("Hello World");
});
// Listen to port for request
App.listen(App.get("port"), App.get("host"), function () {
console.log(`Express server listening on ${App.get("host")}:${App.get("port")}`);
});