Skip to content

Commit

Permalink
Setup app insights, other startup additions.
Browse files Browse the repository at this point in the history
  • Loading branch information
roncli committed Jan 20, 2021
1 parent 45ab813 commit 57bf08a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions node/index.js
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down Expand Up @@ -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";
Expand All @@ -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 {
Expand Down Expand Up @@ -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();
});

Expand Down

0 comments on commit 57bf08a

Please sign in to comment.