From 57bf08a880fecbdcf815b99e899bcef7433b95e8 Mon Sep 17 00:00:00 2001 From: "Ronald M. Clifford" Date: Wed, 20 Jan 2021 01:32:53 -0800 Subject: [PATCH] Setup app insights, other startup additions. --- node/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/node/index.js b/node/index.js index 27496a2c..68245fcc 100644 --- a/node/index.js +++ b/node/index.js @@ -1,4 +1,5 @@ -const bodyParser = require("body-parser"), +const appInsights = require("applicationinsights"), + bodyParser = require("body-parser"), compression = require("compression"), cookieParser = require("cookie-parser"), express = require("express"), @@ -29,6 +30,10 @@ process.on("unhandledRejection", (reason) => { (async function startup() { Log.log("Starting up..."); + // Setup application insights. + appInsights.setup().setAutoCollectRequests(false); + appInsights.start(); + // Set title. if (process.platform === "win32") { process.title = "Six Gaming"; @@ -39,6 +44,9 @@ process.on("unhandledRejection", (reason) => { // Setup express app. const app = express(); + // Remove powered by. + app.disable("x-powered-by"); + // Get the router. const router = new Router(); try { @@ -71,7 +79,7 @@ process.on("unhandledRejection", (reason) => { // Set req.ip. app.use((req, res, next) => { - req.ip = (req.headers["x-forwarded-for"] ? req.headers["x-forwarded-for"].toString() : void 0) || req.ip; + req.ip = (req.headers["x-forwarded-for"] ? req.headers["x-forwarded-for"].toString() : void 0) || req.ip || req.connection.remoteAddress; next(); });