forked from try-panwiac/vulnerable-front-end
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
48 lines (43 loc) · 1.37 KB
/
server.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var request = require("request")
, express = require("express")
, morgan = require("morgan")
, path = require("path")
, bodyParser = require("body-parser")
, async = require("async")
, cookieParser = require("cookie-parser")
, session = require("express-session")
, epimetheus = require("epimetheus")
, config = require("./config")
, helpers = require("./helpers")
, cart = require("./api/cart")
, catalogue = require("./api/catalogue")
, orders = require("./api/orders")
, user = require("./api/user")
, app = express()
epimetheus.instrument(app);
app.use(express.static("public"));
app.use(session(config.session));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(helpers.errorHandler);
app.use(helpers.sessionMiddleware);
app.use(morgan("dev", {}));
var domain = "";
process.argv.forEach(function (val, index, array) {
var arg = val.split("=");
if (arg.length > 1) {
if (arg[0] == "--domain") {
domain = arg[1];
console.log("Setting domain to:", domain);
}
}
});
/* Mount API endpoints */
app.use(cart);
app.use(catalogue);
app.use(orders);
app.use(user);
var server = app.listen(process.env.PORT || 8079, function () {
var port = server.address().port;
console.log("App now running in %s mode on port %d", app.get("env"), port);
});