@evanion/nestjs-correlation-id 1.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ RELEASE 1.0.0
2
+
3
+ - Initial release
@@ -0,0 +1,31 @@
1
+ # Contributing
2
+
3
+ 1. [Fork it](https://help.github.com/articles/fork-a-repo/)
4
+ 2. Install dependencies (`npm install`)
5
+ 3. Create your feature branch (`git checkout -b my-new-feature`)
6
+ 4. Commit your changes (`git commit -am 'Added some feature'`)
7
+ 5. Test your changes (`npm test`)
8
+ 6. Push to the branch (`git push origin my-new-feature`)
9
+ 7. [Create new Pull Request](https://help.github.com/articles/creating-a-pull-request/)
10
+
11
+ ## Testing
12
+
13
+ We use [Jest](https://github.com/facebook/jest) to write tests. Run our test suite with this command:
14
+
15
+ ```
16
+ npm test
17
+ ```
18
+
19
+ ## Code Style
20
+
21
+ We use [Prettier](https://prettier.io/) and tslint to maintain code style and best practices.
22
+ Please make sure your PR adheres to the guides by running:
23
+
24
+ ```
25
+ npm run format
26
+ ```
27
+
28
+ and
29
+ ```
30
+ npm run lint
31
+ ```
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 John Biundo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ <h1 align="center">Nest.js Correlation ID middleware</h1>
2
+
3
+ <h3 align="center">Transparently include correlation IDs in all requests</h3>
4
+
5
+ <div align="center">
6
+ <a href="https://nestjs.com" target="_blank">
7
+ <img src="https://img.shields.io/badge/built%20with-NestJs-red.svg" alt="Built with NestJS">
8
+ </a>
9
+ </div>
10
+
11
+ ### Why?
12
+
13
+ When debugging an issue in your applications logs, it helps to be able to follow a specific request up and down your whole stack. This is usually done by including a `correlation-id` (aka `Request-id`) header in all your requests, and forwarding the same id across all your microservices.
14
+
15
+ ### Installation
16
+
17
+ ```bash
18
+ yarn add @evanion/nestjs-correlation-id
19
+ ```
20
+
21
+ ```bash
22
+ npm install @evanion/nestjs-correlation-id
23
+ ```
24
+
25
+ ### How to use
26
+
27
+ Add the middleware to your `AppModule`
28
+
29
+ ```ts
30
+ import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
31
+ import {
32
+ CorrelationIdMiddleware,
33
+ CorrelationModule,
34
+ } from '@evanion/nestjs-correlation-id';
35
+
36
+ @Module({
37
+ imports: [CorrelationModule.forRoot()],
38
+ })
39
+ export class AppModule implements NestModule {
40
+ configure(consumer: MiddlewareConsumer) {
41
+ consumer.apply(CorrelationIdMiddleware).forRoutes('*');
42
+ }
43
+ }
44
+ ```
45
+
46
+ And then just inject the correlation middleware in your HttpService by calling the `registerAsync` method with the `withCorrelation` function.
47
+
48
+ ```ts
49
+ import { HttpModule } from '@nestjs/axios';
50
+ import { withCorrelation } from '@evanion/nestjs-correlation-id';
51
+
52
+ @Module({
53
+ imports: [HttpModule.registerAsync(withCorrelation())],
54
+ controllers: [UsersController],
55
+ providers: [UsersService],
56
+ })
57
+ export class UsersModule {}
58
+ ```
59
+
60
+ You can now use the `HttpService` as usual in your `UsersService` and `UsersController`
61
+
62
+ ### Customize
63
+
64
+ You can easily customize the header and ID by including a config when you register the module
65
+
66
+ ```ts
67
+ @Module({
68
+ imports: [CorrelationModule.forRoot({
69
+ header: string
70
+ generator: () => string
71
+ })]
72
+ })
73
+ export class AppModule implements NestModule {
74
+ configure(consumer: MiddlewareConsumer) {
75
+ consumer.apply(CorrelationIdMiddleware).forRoutes('*');
76
+ }
77
+ }
78
+ ```
79
+
80
+ see [e2e tests](/test) for a fully working example
81
+
82
+ ## Change Log
83
+
84
+ See [Changelog](CHANGELOG.md) for more information.
85
+
86
+ ## Contributing
87
+
88
+ Contributions welcome! See [Contributing](CONTRIBUTING.md).
89
+
90
+ ## Author
91
+
92
+ **Mikael Pettersson (Evanion on [Discord](https://discord.gg/G7Qnnhy))**
93
+
94
+ ## License
95
+
96
+ Licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,2 @@
1
+ export declare const CORRELATION_ID_HEADER = "X-Correlation-Id";
2
+ export declare const CORRELATION_CONFIG_TOKEN = "CORRELATION_CONFIG";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CORRELATION_CONFIG_TOKEN = exports.CORRELATION_ID_HEADER = void 0;
4
+ exports.CORRELATION_ID_HEADER = 'X-Correlation-Id';
5
+ exports.CORRELATION_CONFIG_TOKEN = 'CORRELATION_CONFIG';
@@ -0,0 +1,10 @@
1
+ import { NestMiddleware } from '@nestjs/common';
2
+ import { Request, Response } from 'express';
3
+ import { CorrelationService } from './correlation.service';
4
+ import { CorrelationConfig } from './interfaces/correlation-config.interface';
5
+ export declare class CorrelationIdMiddleware implements NestMiddleware {
6
+ private correlationService;
7
+ private correlationConfig;
8
+ constructor(correlationService: CorrelationService, correlationConfig: CorrelationConfig);
9
+ use(req: Request, res: Response, next: () => void): void;
10
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CorrelationIdMiddleware = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const constants_1 = require("./constants");
18
+ const correlation_service_1 = require("./correlation.service");
19
+ let CorrelationIdMiddleware = class CorrelationIdMiddleware {
20
+ constructor(correlationService, correlationConfig) {
21
+ this.correlationService = correlationService;
22
+ this.correlationConfig = correlationConfig;
23
+ }
24
+ use(req, res, next) {
25
+ const { header } = this.correlationConfig;
26
+ const correlationId = req.get(header) || this.correlationService.getCorrelationId();
27
+ if (!req.headers[header])
28
+ req.headers[header] = correlationId;
29
+ if (!res.get(header))
30
+ res.set(header, correlationId);
31
+ this.correlationService.setCorrelationId(correlationId);
32
+ next();
33
+ }
34
+ };
35
+ CorrelationIdMiddleware = __decorate([
36
+ (0, common_1.Injectable)(),
37
+ __param(1, (0, common_1.Inject)(constants_1.CORRELATION_CONFIG_TOKEN)),
38
+ __metadata("design:paramtypes", [correlation_service_1.CorrelationService, Object])
39
+ ], CorrelationIdMiddleware);
40
+ exports.CorrelationIdMiddleware = CorrelationIdMiddleware;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const correlation_id_middleware_1 = require("./correlation-id.middleware");
4
+ const mockCorrelationConfig = {
5
+ header: 'x-correlation-id',
6
+ generator: () => '12345',
7
+ };
8
+ const mockCorrelationService = {
9
+ getCorrelationId: jest.fn().mockImplementation(() => 'test123'),
10
+ setCorrelationId: jest.fn(),
11
+ };
12
+ describe('CorrelationIdMiddleware', () => {
13
+ let middleware;
14
+ beforeEach(() => {
15
+ middleware = new correlation_id_middleware_1.CorrelationIdMiddleware(mockCorrelationService, mockCorrelationConfig);
16
+ });
17
+ it('should be defined', () => {
18
+ expect(middleware).toBeDefined();
19
+ });
20
+ it('should set the correlation id in request object', () => {
21
+ const req = {
22
+ get: jest.fn(),
23
+ headers: {},
24
+ };
25
+ const res = {
26
+ get: jest.fn(),
27
+ set: jest.fn(),
28
+ headers: {},
29
+ };
30
+ jest.spyOn(res, 'set');
31
+ middleware.use(req, res, jest.fn());
32
+ expect(req.headers['x-correlation-id']).toBe('test123');
33
+ });
34
+ it('should set the correlation id in response object', () => {
35
+ const req = {
36
+ get: jest.fn().mockImplementation(() => 'test123'),
37
+ headers: {},
38
+ };
39
+ const res = {
40
+ get: jest.fn(),
41
+ set: jest.fn(),
42
+ headers: {},
43
+ };
44
+ jest.spyOn(res, 'set');
45
+ middleware.use(req, res, () => { });
46
+ expect(res.set).toHaveBeenCalledWith('x-correlation-id', 'test123');
47
+ });
48
+ it('should set the correlation id in correlationService', () => {
49
+ const req = {
50
+ get: jest.fn().mockImplementation(() => 'test123'),
51
+ headers: {},
52
+ };
53
+ const res = {
54
+ get: jest.fn(),
55
+ set: jest.fn(),
56
+ headers: {},
57
+ };
58
+ jest.spyOn(res, 'set');
59
+ middleware.use(req, res, jest.fn());
60
+ expect(mockCorrelationService.setCorrelationId).toHaveBeenCalledWith('test123');
61
+ });
62
+ });
@@ -0,0 +1,5 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { CorrelationConfig } from './interfaces/correlation-config.interface';
3
+ export declare class CorrelationModule {
4
+ static forRoot(config?: Partial<CorrelationConfig>): DynamicModule;
5
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var CorrelationModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.CorrelationModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const uuid_1 = require("uuid");
13
+ const constants_1 = require("./constants");
14
+ const correlation_service_1 = require("./correlation.service");
15
+ let CorrelationModule = CorrelationModule_1 = class CorrelationModule {
16
+ static forRoot(config) {
17
+ const correlationConfigProvider = {
18
+ provide: constants_1.CORRELATION_CONFIG_TOKEN,
19
+ useValue: Object.assign(Object.assign({}, config), { header: (config === null || config === void 0 ? void 0 : config.header) || constants_1.CORRELATION_ID_HEADER, generator: (config === null || config === void 0 ? void 0 : config.generator) || uuid_1.v4 }),
20
+ };
21
+ return {
22
+ global: true,
23
+ module: CorrelationModule_1,
24
+ providers: [correlationConfigProvider, correlation_service_1.CorrelationService],
25
+ exports: [correlationConfigProvider, correlation_service_1.CorrelationService],
26
+ };
27
+ }
28
+ };
29
+ CorrelationModule = CorrelationModule_1 = __decorate([
30
+ (0, common_1.Module)({})
31
+ ], CorrelationModule);
32
+ exports.CorrelationModule = CorrelationModule;
@@ -0,0 +1,7 @@
1
+ import { CorrelationConfig } from './interfaces/correlation-config.interface';
2
+ export declare class CorrelationService {
3
+ private correlationId;
4
+ constructor(correlationConfig: CorrelationConfig);
5
+ getCorrelationId(): string;
6
+ setCorrelationId(correlationId: string): void;
7
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CorrelationService = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const uuid_1 = require("uuid");
18
+ const constants_1 = require("./constants");
19
+ let CorrelationService = class CorrelationService {
20
+ constructor(correlationConfig) {
21
+ this.correlationId = correlationConfig.generator
22
+ ? correlationConfig.generator()
23
+ : (0, uuid_1.v4)();
24
+ }
25
+ getCorrelationId() {
26
+ return this.correlationId;
27
+ }
28
+ setCorrelationId(correlationId) {
29
+ this.correlationId = correlationId;
30
+ }
31
+ };
32
+ CorrelationService = __decorate([
33
+ (0, common_1.Injectable)({ scope: common_1.Scope.REQUEST }),
34
+ __param(0, (0, common_1.Inject)(constants_1.CORRELATION_CONFIG_TOKEN)),
35
+ __metadata("design:paramtypes", [Object])
36
+ ], CorrelationService);
37
+ exports.CorrelationService = CorrelationService;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const testing_1 = require("@nestjs/testing");
13
+ const constants_1 = require("./constants");
14
+ const correlation_service_1 = require("./correlation.service");
15
+ describe('CorrelationService', () => {
16
+ let service;
17
+ beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
18
+ const module = yield testing_1.Test.createTestingModule({
19
+ providers: [
20
+ correlation_service_1.CorrelationService,
21
+ {
22
+ provide: constants_1.CORRELATION_CONFIG_TOKEN,
23
+ useValue: {
24
+ header: constants_1.CORRELATION_ID_HEADER,
25
+ generator: () => 'test-id',
26
+ },
27
+ },
28
+ ],
29
+ }).compile();
30
+ service = yield module.resolve(correlation_service_1.CorrelationService);
31
+ }));
32
+ it('should be defined', () => {
33
+ expect(service).toBeDefined();
34
+ });
35
+ });
@@ -0,0 +1,5 @@
1
+ export * from './correlation-id.middleware';
2
+ export * from './correlation.service';
3
+ export * from './correlation.module';
4
+ export * from './withCorrelation.function';
5
+ export * from './constants';
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./correlation-id.middleware"), exports);
18
+ __exportStar(require("./correlation.service"), exports);
19
+ __exportStar(require("./correlation.module"), exports);
20
+ __exportStar(require("./withCorrelation.function"), exports);
21
+ __exportStar(require("./constants"), exports);
@@ -0,0 +1,4 @@
1
+ export interface CorrelationConfig {
2
+ header: string;
3
+ generator: () => string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,50 @@
1
+ import { HttpModuleOptions } from '@nestjs/axios';
2
+ import { CorrelationModule } from './correlation.module';
3
+ import { CorrelationService } from './correlation.service';
4
+ export declare const withCorrelation: (config?: HttpModuleOptions) => {
5
+ imports: (typeof CorrelationModule)[];
6
+ useFactory: (correlationService: CorrelationService) => Promise<{
7
+ headers: {
8
+ "X-Correlation-Id": string;
9
+ };
10
+ url?: string;
11
+ method?: string;
12
+ baseURL?: string;
13
+ transformRequest?: import("axios").AxiosRequestTransformer | import("axios").AxiosRequestTransformer[];
14
+ transformResponse?: import("axios").AxiosResponseTransformer | import("axios").AxiosResponseTransformer[];
15
+ params?: any;
16
+ paramsSerializer?: (params: any) => string;
17
+ data?: any;
18
+ timeout?: number;
19
+ timeoutErrorMessage?: string;
20
+ withCredentials?: boolean;
21
+ adapter?: import("axios").AxiosAdapter;
22
+ auth?: import("axios").AxiosBasicCredentials;
23
+ responseType?: import("axios").ResponseType;
24
+ responseEncoding?: string;
25
+ xsrfCookieName?: string;
26
+ xsrfHeaderName?: string;
27
+ onUploadProgress?: (progressEvent: any) => void;
28
+ onDownloadProgress?: (progressEvent: any) => void;
29
+ maxContentLength?: number;
30
+ validateStatus?: (status: number) => boolean;
31
+ maxBodyLength?: number;
32
+ maxRedirects?: number;
33
+ beforeRedirect?: (options: Record<string, any>, responseDetails: {
34
+ headers: Record<string, string>;
35
+ }) => void;
36
+ socketPath?: string;
37
+ httpAgent?: any;
38
+ httpsAgent?: any;
39
+ proxy?: false | import("axios").AxiosProxyConfig;
40
+ cancelToken?: import("axios").CancelToken;
41
+ decompress?: boolean;
42
+ transitional?: import("axios").TransitionalOptions;
43
+ signal?: AbortSignal;
44
+ insecureHTTPParser?: boolean;
45
+ env?: {
46
+ FormData?: new (...args: any[]) => object;
47
+ };
48
+ }>;
49
+ inject: (typeof CorrelationService)[];
50
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.withCorrelation = void 0;
13
+ const constants_1 = require("./constants");
14
+ const correlation_module_1 = require("./correlation.module");
15
+ const correlation_service_1 = require("./correlation.service");
16
+ const withCorrelation = (config) => ({
17
+ imports: [correlation_module_1.CorrelationModule],
18
+ useFactory: (correlationService) => __awaiter(void 0, void 0, void 0, function* () {
19
+ return (Object.assign(Object.assign({}, config), { headers: Object.assign(Object.assign({}, ((config === null || config === void 0 ? void 0 : config.headers) && config.headers)), { [constants_1.CORRELATION_ID_HEADER]: correlationService.getCorrelationId() }) }));
20
+ }),
21
+ inject: [correlation_service_1.CorrelationService],
22
+ });
23
+ exports.withCorrelation = withCorrelation;
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@evanion/nestjs-correlation-id",
3
+ "version": "1.0.0",
4
+ "description": "Transparently forward or add correlation id to all requests",
5
+ "author": "Mikael Pettersson <evanion@icloud.com>",
6
+ "license": "MIT",
7
+ "readmeFilename": "README.md",
8
+ "main": "dist/index.js",
9
+ "files": [
10
+ "dist/**/*",
11
+ "*.md"
12
+ ],
13
+ "scripts": {
14
+ "start:dev": "tsc -w",
15
+ "build": "tsc",
16
+ "prepare": "npm run build",
17
+ "format": "prettier --write \"src/**/*.ts\"",
18
+ "lint": "eslint \"src/**/*.ts\"",
19
+ "lint:fix": "eslint --fix \"src/**/*.ts\"",
20
+ "test": "jest",
21
+ "test:watch": "jest --watch",
22
+ "test:cov": "jest --coverage",
23
+ "test:e2e": "jest --config ./test/jest-e2e.json"
24
+ },
25
+ "keywords": [
26
+ "nestjs",
27
+ "nestjs-middleware",
28
+ "middleware",
29
+ "correlation",
30
+ "correlation-id",
31
+ "request",
32
+ "request-id"
33
+ ],
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/evanion/nestjs-correlation-id"
40
+ },
41
+ "bugs": "https://github.com/evanion/nestjs-correlation-id/issues",
42
+ "peerDependencies": {
43
+ "@nestjs/axios": "^0.1.0",
44
+ "@nestjs/common": "^6.0.0"
45
+ },
46
+ "dependencies": {},
47
+ "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",
56
+ "@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",
64
+ "reflect-metadata": "^0.1.13",
65
+ "rxjs": "^7.5.5",
66
+ "supertest": "6.2.4",
67
+ "ts-jest": "28.0.5",
68
+ "ts-node": "10.8.2",
69
+ "tsc-watch": "5.0.3",
70
+ "tsconfig-paths": "4.0.0",
71
+ "typescript": "4.7.4"
72
+ }
73
+ }