@evanion/nestjs-correlation-id 1.0.3 → 1.1.0

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.
package/README.md CHANGED
@@ -84,10 +84,10 @@ In order to add the correlation ID to your logs, you can use the `CorrelationSer
84
84
  In the following example, we are using the [@ntegral/nestjs-sentry](https://github.com/ntegral/nestjs-sentry) package, but you can use any package or provider you like.
85
85
 
86
86
  ```ts
87
- import { Injectable, NestMiddleware } from '@nestjs/common';
88
- import { Request, Response } from 'express';
89
87
  import { CorrelationService } from '@evanion/nestjs-correlation-id';
88
+ import { Injectable, NestMiddleware } from '@nestjs/common';
90
89
  import { InjectSentry, SentryService } from '@ntegral/nestjs-sentry';
90
+ import { NextFunction, Request, Response } from 'express';
91
91
 
92
92
  @Injectable()
93
93
  export class SentryMiddleware implements NestMiddleware {
@@ -96,9 +96,9 @@ export class SentryMiddleware implements NestMiddleware {
96
96
  @InjectSentry() private readonly sentryService: SentryService,
97
97
  ) {}
98
98
 
99
- async use(req: Request, res: Response, next) {
99
+ async use(_req: Request, _res: Response, next: NextFunction) {
100
100
  const correlationId = await this.correlationService.getCorrelationId();
101
- this.sentryService.configureScope((scope) => {
101
+ this.sentryService.instance().configureScope((scope) => {
102
102
  scope.setTag('correlationId', correlationId);
103
103
  });
104
104
  next();
@@ -110,15 +110,9 @@ Then add it to your `AppModule`
110
110
 
111
111
  ```ts
112
112
  import { Module } from '@nestjs-common';
113
- import {
114
- SentryModule,
115
- ConfigModule,
116
- ConfigService,
117
- } from '@ntegral/nestjs-sentry';
118
- import {
119
- CorrelationModule,
120
- CorrelationService,
121
- } from '@evanion/nestjs-correlation-id';
113
+ import { SentryModule } from '@ntegral/nestjs-sentry';
114
+ import { CorrelationModule } from '@evanion/nestjs-correlation-id';
115
+ import { SentryMiddleware } from './middleware/sentry.middleware';
122
116
 
123
117
  @Module({
124
118
  imports: [
@@ -134,8 +128,6 @@ export class AppModule implements NestModule {
134
128
  consumer.apply(SentryMiddleware).forRoutes('*');
135
129
  }
136
130
  }
137
- {
138
- }
139
131
  ```
140
132
 
141
133
  If you need to manually set the correlationId anywhere in your application. You can use the `CorrelationService` service to set the correlationId.
@@ -16,7 +16,7 @@ exports.CorrelationIdMiddleware = void 0;
16
16
  const common_1 = require("@nestjs/common");
17
17
  const constants_1 = require("./constants");
18
18
  const correlation_service_1 = require("./correlation.service");
19
- let CorrelationIdMiddleware = class CorrelationIdMiddleware {
19
+ let CorrelationIdMiddleware = exports.CorrelationIdMiddleware = class CorrelationIdMiddleware {
20
20
  constructor(correlationService, correlationConfig) {
21
21
  this.correlationService = correlationService;
22
22
  this.correlationConfig = correlationConfig;
@@ -32,9 +32,8 @@ let CorrelationIdMiddleware = class CorrelationIdMiddleware {
32
32
  next();
33
33
  }
34
34
  };
35
- CorrelationIdMiddleware = __decorate([
35
+ exports.CorrelationIdMiddleware = CorrelationIdMiddleware = __decorate([
36
36
  (0, common_1.Injectable)(),
37
37
  __param(1, (0, common_1.Inject)(constants_1.CORRELATION_CONFIG_TOKEN)),
38
38
  __metadata("design:paramtypes", [correlation_service_1.CorrelationService, Object])
39
39
  ], CorrelationIdMiddleware);
40
- exports.CorrelationIdMiddleware = CorrelationIdMiddleware;
@@ -12,7 +12,7 @@ const common_1 = require("@nestjs/common");
12
12
  const uuid_1 = require("uuid");
13
13
  const constants_1 = require("./constants");
14
14
  const correlation_service_1 = require("./correlation.service");
15
- let CorrelationModule = CorrelationModule_1 = class CorrelationModule {
15
+ let CorrelationModule = exports.CorrelationModule = CorrelationModule_1 = class CorrelationModule {
16
16
  static forRoot(config) {
17
17
  const correlationConfigProvider = {
18
18
  provide: constants_1.CORRELATION_CONFIG_TOKEN,
@@ -26,7 +26,6 @@ let CorrelationModule = CorrelationModule_1 = class CorrelationModule {
26
26
  };
27
27
  }
28
28
  };
29
- CorrelationModule = CorrelationModule_1 = __decorate([
29
+ exports.CorrelationModule = CorrelationModule = CorrelationModule_1 = __decorate([
30
30
  (0, common_1.Module)({})
31
31
  ], CorrelationModule);
32
- exports.CorrelationModule = CorrelationModule;
@@ -16,7 +16,7 @@ exports.CorrelationService = void 0;
16
16
  const common_1 = require("@nestjs/common");
17
17
  const uuid_1 = require("uuid");
18
18
  const constants_1 = require("./constants");
19
- let CorrelationService = class CorrelationService {
19
+ let CorrelationService = exports.CorrelationService = class CorrelationService {
20
20
  constructor(correlationConfig) {
21
21
  this.correlationId = correlationConfig.generator
22
22
  ? correlationConfig.generator()
@@ -29,9 +29,8 @@ let CorrelationService = class CorrelationService {
29
29
  this.correlationId = correlationId;
30
30
  }
31
31
  };
32
- CorrelationService = __decorate([
32
+ exports.CorrelationService = CorrelationService = __decorate([
33
33
  (0, common_1.Injectable)({ scope: common_1.Scope.REQUEST }),
34
34
  __param(0, (0, common_1.Inject)(constants_1.CORRELATION_CONFIG_TOKEN)),
35
35
  __metadata("design:paramtypes", [Object])
36
36
  ], CorrelationService);
37
- exports.CorrelationService = CorrelationService;
@@ -6,6 +6,25 @@ export declare const withCorrelation: (config?: HttpModuleOptions) => {
6
6
  useFactory: (correlationService: CorrelationService) => Promise<{
7
7
  headers: {
8
8
  "X-Correlation-Id": string;
9
+ } | {
10
+ "X-Correlation-Id": string;
11
+ Accept?: import("axios").AxiosHeaderValue;
12
+ "Content-Length"?: import("axios").AxiosHeaderValue;
13
+ "User-Agent"?: import("axios").AxiosHeaderValue;
14
+ "Content-Encoding"?: import("axios").AxiosHeaderValue;
15
+ Authorization?: import("axios").AxiosHeaderValue;
16
+ 'Content-Type'?: import("axios").AxiosHeaderValue;
17
+ link?: import("axios").AxiosHeaders;
18
+ head?: import("axios").AxiosHeaders;
19
+ options?: import("axios").AxiosHeaders;
20
+ get?: import("axios").AxiosHeaders;
21
+ post?: import("axios").AxiosHeaders;
22
+ put?: import("axios").AxiosHeaders;
23
+ delete?: import("axios").AxiosHeaders;
24
+ patch?: import("axios").AxiosHeaders;
25
+ purge?: import("axios").AxiosHeaders;
26
+ unlink?: import("axios").AxiosHeaders;
27
+ common?: import("axios").AxiosHeaders;
9
28
  };
10
29
  url?: string;
11
30
  method?: string;
@@ -13,38 +32,43 @@ export declare const withCorrelation: (config?: HttpModuleOptions) => {
13
32
  transformRequest?: import("axios").AxiosRequestTransformer | import("axios").AxiosRequestTransformer[];
14
33
  transformResponse?: import("axios").AxiosResponseTransformer | import("axios").AxiosResponseTransformer[];
15
34
  params?: any;
16
- paramsSerializer?: (params: any) => string;
35
+ paramsSerializer?: import("axios").CustomParamsSerializer | import("axios").ParamsSerializerOptions;
17
36
  data?: any;
18
37
  timeout?: number;
19
38
  timeoutErrorMessage?: string;
20
39
  withCredentials?: boolean;
21
- adapter?: import("axios").AxiosAdapter;
40
+ adapter?: (string | import("axios").AxiosAdapter) | (string | import("axios").AxiosAdapter)[];
22
41
  auth?: import("axios").AxiosBasicCredentials;
23
42
  responseType?: import("axios").ResponseType;
24
43
  responseEncoding?: string;
25
44
  xsrfCookieName?: string;
26
45
  xsrfHeaderName?: string;
27
- onUploadProgress?: (progressEvent: any) => void;
28
- onDownloadProgress?: (progressEvent: any) => void;
46
+ onUploadProgress?: (progressEvent: import("axios").AxiosProgressEvent) => void;
47
+ onDownloadProgress?: (progressEvent: import("axios").AxiosProgressEvent) => void;
29
48
  maxContentLength?: number;
30
49
  validateStatus?: (status: number) => boolean;
31
50
  maxBodyLength?: number;
32
51
  maxRedirects?: number;
52
+ maxRate?: number | [number, number];
33
53
  beforeRedirect?: (options: Record<string, any>, responseDetails: {
34
54
  headers: Record<string, string>;
35
55
  }) => void;
36
56
  socketPath?: string;
57
+ transport?: any;
37
58
  httpAgent?: any;
38
59
  httpsAgent?: any;
39
60
  proxy?: false | import("axios").AxiosProxyConfig;
40
61
  cancelToken?: import("axios").CancelToken;
41
62
  decompress?: boolean;
42
63
  transitional?: import("axios").TransitionalOptions;
43
- signal?: AbortSignal;
64
+ signal?: import("axios").GenericAbortSignal;
44
65
  insecureHTTPParser?: boolean;
45
66
  env?: {
46
67
  FormData?: new (...args: any[]) => object;
47
68
  };
69
+ formSerializer?: import("axios").FormSerializerOptions;
70
+ family?: 4 | 6;
71
+ lookup?: ((hostname: string, options: object, cb: (err: Error, address: string, family: number) => void) => void) | ((hostname: string, options: object) => Promise<string | [address: string, family: number]>);
48
72
  }>;
49
73
  inject: (typeof CorrelationService)[];
50
74
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanion/nestjs-correlation-id",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Transparently forward or add correlation id to all requests",
5
5
  "author": "Mikael Pettersson <evanion@icloud.com>",
6
6
  "license": "MIT",
@@ -41,34 +41,38 @@
41
41
  },
42
42
  "bugs": "https://github.com/evanion/nestjs-correlation-id/issues",
43
43
  "peerDependencies": {
44
- "@nestjs/axios": "^0.1.0",
45
- "@nestjs/common": "^6.0.0"
44
+ "@nestjs/axios": "^0.1.0 || ^1.0.0 || ^2.0.0 || ^3.00",
45
+ "@nestjs/common": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0"
46
+ },
47
+ "dependencies": {
48
+ "uuid": "^9.0.0"
46
49
  },
47
50
  "devDependencies": {
48
- "@nestjs/axios": "^0.1.0",
49
- "@nestjs/common": "^9.0.1",
50
- "@nestjs/core": "^9.0.1",
51
- "@nestjs/platform-express": "^9.0.1",
52
- "@nestjs/testing": "9.0.1",
53
- "@types/express": "4.17.13",
54
- "@types/jest": "28.1.4",
55
- "@types/node": "18.0.3",
51
+ "@nestjs/axios": "^3.0.0",
52
+ "@nestjs/common": "^10.0.5",
53
+ "@nestjs/core": "^10.0.5",
54
+ "@nestjs/platform-express": "^10.0.5",
55
+ "@nestjs/testing": "10.0.5",
56
+ "@types/express": "4.17.17",
57
+ "@types/jest": "29.5.3",
56
58
  "@types/supertest": "2.0.12",
57
- "@typescript-eslint/eslint-plugin": "^5.30.5",
58
- "@typescript-eslint/parser": "^5.30.5",
59
- "eslint": "^8.19.0",
60
- "eslint-config-prettier": "^8.5.0",
61
- "eslint-plugin-prettier": "^4.2.1",
62
- "jest": "28.1.2",
63
- "prettier": "^2.7.1",
59
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
60
+ "@typescript-eslint/parser": "^6.0.0",
61
+ "axios": "^1.4.0",
62
+ "eslint": "^8.44.0",
63
+ "eslint-config-prettier": "^8.8.0",
64
+ "eslint-plugin-prettier": "^5.0.0",
65
+ "jest": "29.6.1",
66
+ "prettier": "^3.0.0",
64
67
  "reflect-metadata": "^0.1.13",
65
- "release-it": "^15.1.1",
66
- "rxjs": "^7.5.5",
67
- "supertest": "6.2.4",
68
- "ts-jest": "28.0.5",
69
- "ts-node": "10.8.2",
70
- "tsc-watch": "5.0.3",
71
- "tsconfig-paths": "4.0.0",
72
- "typescript": "4.7.4"
68
+ "release-it": "^16.1.0",
69
+ "rxjs": "^7.8.1",
70
+ "supertest": "6.3.3",
71
+ "ts-jest": "29.1.1",
72
+ "ts-node": "10.9.1",
73
+ "tsc-watch": "6.0.4",
74
+ "tsconfig-paths": "4.2.0",
75
+ "typescript": "5.1.6",
76
+ "uuid": "^9.0.0"
73
77
  }
74
78
  }