@abyss-project/monitor 1.0.32 → 1.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ type Options = {
7
7
  middlewares: any[];
8
8
  controllers: any[];
9
9
  router: (option: any) => Router;
10
+ disableTrustProxy?: boolean;
10
11
  };
11
12
  export declare const controllerLoader: (app: express.Application, options: Options) => Promise<{
12
13
  swagger: {
@@ -23,6 +23,9 @@ const types_1 = require("../../types");
23
23
  const controllerLoader = async (app, options) => {
24
24
  var _a, _b, _c, _d;
25
25
  try {
26
+ if (options.disableTrustProxy !== true) {
27
+ app.set('trust proxy', true);
28
+ }
26
29
  const middlewares = options.middlewares.map((middleware) => new middleware());
27
30
  const controllers = options.controllers;
28
31
  const tags = [];
@@ -21,11 +21,22 @@ const loggerEndpointMiddleware = async (logger, req, res, next, callback) => {
21
21
  try {
22
22
  res.locals.timer.durationToClose = getDurationInMilliseconds(res.locals.timer.startTime);
23
23
  if (!res.locals.shouldNotPublishLog) {
24
- const ips = Array.isArray(req.headers['x-forwarded-for'])
25
- ? req.headers['x-forwarded-for']
26
- : [...(req.headers['x-forwarded-for'] ? [req.headers['x-forwarded-for']] : [])];
27
- ips.push(...(req.socket.remoteAddress ? [req.socket.remoteAddress] : []));
28
- ips.push(...(req.ip ? [req.ip] : []));
24
+ const ips = [];
25
+ const forwardedFor = req.headers['x-forwarded-for'];
26
+ if (forwardedFor) {
27
+ if (Array.isArray(forwardedFor)) {
28
+ ips.push(...forwardedFor);
29
+ }
30
+ else {
31
+ ips.push(forwardedFor);
32
+ }
33
+ }
34
+ if (req.socket.remoteAddress) {
35
+ ips.push(req.socket.remoteAddress);
36
+ }
37
+ if (req.ip) {
38
+ ips.push(req.ip);
39
+ }
29
40
  await logger.log('', {
30
41
  requestId,
31
42
  context: 'API',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/monitor",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "description": "Core package to interact with Abyss-Monitor",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",