@abyss-project/monitor 1.0.31 → 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.
@@ -1,3 +1,4 @@
1
- import { IGetLatencySentinelMetricsParams, IGetLatencySentinelMetricsQuery, IGetLatencySentinelMetricsResponse, IGetSentinelMetricsParams, IGetSentinelMetricsQuery, IGetSentinelMetricsResponse } from '../types';
1
+ import { IGetLastIncidentSentinelMetricsParams, IGetLastIncidentSentinelMetricsQuery, IGetLastIncidentSentinelMetricsResponse, IGetLatencySentinelMetricsParams, IGetLatencySentinelMetricsQuery, IGetLatencySentinelMetricsResponse, IGetSentinelMetricsParams, IGetSentinelMetricsQuery, IGetSentinelMetricsResponse } from '../types';
2
2
  export declare const getSentinelMetrics: (params: IGetSentinelMetricsParams, query: IGetSentinelMetricsQuery) => Promise<IGetSentinelMetricsResponse>;
3
3
  export declare const getLatencySentinelMetrics: (params: IGetLatencySentinelMetricsParams, query: IGetLatencySentinelMetricsQuery) => Promise<IGetLatencySentinelMetricsResponse>;
4
+ export declare const getLastIncidentSentinelMetrics: (params: IGetLastIncidentSentinelMetricsParams, query: IGetLastIncidentSentinelMetricsQuery) => Promise<IGetLastIncidentSentinelMetricsResponse>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLatencySentinelMetrics = exports.getSentinelMetrics = void 0;
3
+ exports.getLastIncidentSentinelMetrics = exports.getLatencySentinelMetrics = exports.getSentinelMetrics = void 0;
4
4
  const __1 = require("..");
5
5
  const getSentinelMetrics = async (params, query) => {
6
6
  return (await __1.AbyssMonitorCore.axios.get(`metrics/sentinel/${params.projectId}`, { params: query })).data;
@@ -10,3 +10,7 @@ const getLatencySentinelMetrics = async (params, query) => {
10
10
  return (await __1.AbyssMonitorCore.axios.get(`metrics/sentinel/${params.projectId}/latency`, { params: query })).data;
11
11
  };
12
12
  exports.getLatencySentinelMetrics = getLatencySentinelMetrics;
13
+ const getLastIncidentSentinelMetrics = async (params, query) => {
14
+ return (await __1.AbyssMonitorCore.axios.get(`metrics/sentinel/${params.projectId}/last-incident`, { params: query })).data;
15
+ };
16
+ exports.getLastIncidentSentinelMetrics = getLastIncidentSentinelMetrics;
@@ -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',
@@ -13,3 +13,11 @@ export interface IGetLatencySentinelMetricsQuery {
13
13
  startDate?: Date;
14
14
  endDate?: Date;
15
15
  }
16
+ export interface IGetLastIncidentSentinelMetricsParams {
17
+ projectId: string;
18
+ }
19
+ export interface IGetLastIncidentSentinelMetricsQuery {
20
+ applicationIds?: string[];
21
+ startDate?: Date;
22
+ endDate?: Date;
23
+ }
@@ -1,4 +1,4 @@
1
- import { IResponse, IApplicationSentinel } from '../..';
1
+ import { IResponse, IApplicationSentinel, IApplicationSentinelHistory } from '../..';
2
2
  export interface IGetSentinelMetricsData {
3
3
  metrics: {
4
4
  applicationSentinel: IApplicationSentinel[];
@@ -19,3 +19,11 @@ export interface IGetLatencySentinelMetricsData {
19
19
  }>;
20
20
  }
21
21
  export type IGetLatencySentinelMetricsResponse = IResponse<IGetLatencySentinelMetricsData>;
22
+ export interface IGetLastIncidentSentinelMetricsData {
23
+ metrics: {
24
+ incident: IApplicationSentinelHistory;
25
+ sentinel: IApplicationSentinel;
26
+ durationMs: number | null;
27
+ }[];
28
+ }
29
+ export type IGetLastIncidentSentinelMetricsResponse = IResponse<IGetLastIncidentSentinelMetricsData>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/monitor",
3
- "version": "1.0.31",
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",