@infineit/winston-logger 1.0.33 → 1.0.35
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
|
@@ -53,23 +53,20 @@ This package requires the following peer dependencies (usually already installed
|
|
|
53
53
|
|
|
54
54
|
### ⚠️ Critical Setup Requirement
|
|
55
55
|
|
|
56
|
-
**IMPORTANT:** `ClsModule.forRoot()`
|
|
56
|
+
**IMPORTANT:** `ContextModule` internally imports and exports `ClsModule.forRoot()` with `mount: true` and `generateId: true`. **Applications MUST NOT import `ClsModule` separately** - just import `ContextModule`.
|
|
57
57
|
|
|
58
|
-
**Correct import
|
|
58
|
+
**Correct import:**
|
|
59
59
|
```typescript
|
|
60
60
|
@Module({
|
|
61
61
|
imports: [
|
|
62
62
|
ConfigModule.forRoot({ isGlobal: true }),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
LoggerModule.forRoot(), // ✅ THEN - Configures logger
|
|
63
|
+
ContextModule, // ✅ Includes ClsModule internally
|
|
64
|
+
LoggerModule.forRoot(), // ✅ Then configure logger
|
|
66
65
|
],
|
|
67
66
|
})
|
|
68
67
|
```
|
|
69
68
|
|
|
70
|
-
**❌ Incorrect:**
|
|
71
|
-
|
|
72
|
-
**Note:** `ContextModule` does NOT import `ClsModule` internally. Applications must configure `ClsModule.forRoot()` themselves.
|
|
69
|
+
**❌ Incorrect:** Do NOT import `ClsModule.forRoot()` in your `AppModule`. `ContextModule` handles it internally.
|
|
73
70
|
|
|
74
71
|
---
|
|
75
72
|
|
|
@@ -80,26 +77,12 @@ This package requires the following peer dependencies (usually already installed
|
|
|
80
77
|
```typescript
|
|
81
78
|
import { Module } from '@nestjs/common';
|
|
82
79
|
import { ConfigModule } from '@nestjs/config';
|
|
83
|
-
import { ClsModule } from 'nestjs-cls'; // REQUIRED: Must import ClsModule first
|
|
84
|
-
import { v4 as uuidv4 } from 'uuid'; // REQUIRED: For correlation ID generation
|
|
85
80
|
import { ContextModule, LoggerModule } from '@infineit/winston-logger';
|
|
86
81
|
|
|
87
82
|
@Module({
|
|
88
83
|
imports: [
|
|
89
84
|
ConfigModule.forRoot({ isGlobal: true }),
|
|
90
|
-
|
|
91
|
-
// ⚠️ CRITICAL: ClsModule MUST be imported BEFORE ContextModule
|
|
92
|
-
ClsModule.forRoot({
|
|
93
|
-
global: true,
|
|
94
|
-
middleware: {
|
|
95
|
-
mount: true, // Enable middleware for HTTP requests
|
|
96
|
-
generateId: true, // Auto-generate correlation ID
|
|
97
|
-
idGenerator: (req: Request) =>
|
|
98
|
-
(req.headers['x-correlation-id'] as string) || uuidv4(),
|
|
99
|
-
},
|
|
100
|
-
}),
|
|
101
|
-
|
|
102
|
-
ContextModule, // Required for CLS (correlation ID support) - uses existing ClsModule
|
|
85
|
+
ContextModule, // Includes ClsModule internally with mount: true and generateId: true
|
|
103
86
|
LoggerModule.forRoot(), // Configure logger
|
|
104
87
|
],
|
|
105
88
|
})
|
|
@@ -216,22 +199,9 @@ const config: LoggerModuleConfig = {
|
|
|
216
199
|
// kafkaTopic: 'project-logs', // Kafka topic (required if transportType='kafka')
|
|
217
200
|
};
|
|
218
201
|
|
|
219
|
-
import { ClsModule } from 'nestjs-cls';
|
|
220
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
221
|
-
|
|
222
202
|
@Module({
|
|
223
203
|
imports: [
|
|
224
|
-
//
|
|
225
|
-
ClsModule.forRoot({
|
|
226
|
-
global: true,
|
|
227
|
-
middleware: {
|
|
228
|
-
mount: true,
|
|
229
|
-
generateId: true,
|
|
230
|
-
idGenerator: (req: Request) =>
|
|
231
|
-
(req.headers['x-correlation-id'] as string) || uuidv4(),
|
|
232
|
-
},
|
|
233
|
-
}),
|
|
234
|
-
ContextModule, // Uses existing ClsModule
|
|
204
|
+
ContextModule, // Includes ClsModule internally
|
|
235
205
|
LoggerModule.forRoot(config),
|
|
236
206
|
],
|
|
237
207
|
})
|
|
@@ -282,26 +252,13 @@ export default registerAs('logger', () => ({
|
|
|
282
252
|
```
|
|
283
253
|
|
|
284
254
|
```typescript
|
|
285
|
-
import { ClsModule } from 'nestjs-cls';
|
|
286
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
287
|
-
|
|
288
255
|
@Module({
|
|
289
256
|
imports: [
|
|
290
257
|
ConfigModule.forRoot({
|
|
291
258
|
isGlobal: true,
|
|
292
259
|
load: [loggerConfig],
|
|
293
260
|
}),
|
|
294
|
-
//
|
|
295
|
-
ClsModule.forRoot({
|
|
296
|
-
global: true,
|
|
297
|
-
middleware: {
|
|
298
|
-
mount: true,
|
|
299
|
-
generateId: true,
|
|
300
|
-
idGenerator: (req: Request) =>
|
|
301
|
-
(req.headers['x-correlation-id'] as string) || uuidv4(),
|
|
302
|
-
},
|
|
303
|
-
}),
|
|
304
|
-
ContextModule, // Uses existing ClsModule configuration
|
|
261
|
+
ContextModule, // Includes ClsModule internally
|
|
305
262
|
LoggerModule.forRoot(), // Will read from ConfigService
|
|
306
263
|
],
|
|
307
264
|
})
|
|
@@ -397,26 +354,14 @@ export class UserController {
|
|
|
397
354
|
}
|
|
398
355
|
```
|
|
399
356
|
|
|
400
|
-
**Important**: For HTTP services,
|
|
357
|
+
**Important**: For HTTP services, `ContextModule` automatically configures CLS middleware with `mount: true` and `generateId: true`. Correlation IDs are handled automatically.
|
|
401
358
|
|
|
402
359
|
```typescript
|
|
403
|
-
import { ClsModule } from 'nestjs-cls';
|
|
404
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
405
360
|
import { ContextModule, LoggerModule } from '@infineit/winston-logger';
|
|
406
361
|
|
|
407
362
|
@Module({
|
|
408
363
|
imports: [
|
|
409
|
-
//
|
|
410
|
-
ClsModule.forRoot({
|
|
411
|
-
global: true,
|
|
412
|
-
middleware: {
|
|
413
|
-
mount: true, // Enable middleware
|
|
414
|
-
generateId: true, // Auto-generate correlation ID
|
|
415
|
-
idGenerator: (req: Request) =>
|
|
416
|
-
(req.headers['x-correlation-id'] as string) || uuidv4(),
|
|
417
|
-
},
|
|
418
|
-
}),
|
|
419
|
-
ContextModule, // Provides CLS service - uses existing ClsModule
|
|
364
|
+
ContextModule, // Includes ClsModule internally with mount: true and generateId: true
|
|
420
365
|
LoggerModule.forRoot(),
|
|
421
366
|
],
|
|
422
367
|
})
|
|
@@ -610,8 +555,6 @@ export class KafkaTransport implements LoggerTransport {
|
|
|
610
555
|
|
|
611
556
|
```typescript
|
|
612
557
|
import { Provider, Module } from '@nestjs/common';
|
|
613
|
-
import { ClsModule } from 'nestjs-cls';
|
|
614
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
615
558
|
import { ContextModule, LoggerModule } from '@infineit/winston-logger';
|
|
616
559
|
import { KafkaTransport } from './kafka-transport';
|
|
617
560
|
|
|
@@ -624,17 +567,7 @@ const customTransports: Provider[] = [
|
|
|
624
567
|
|
|
625
568
|
@Module({
|
|
626
569
|
imports: [
|
|
627
|
-
//
|
|
628
|
-
ClsModule.forRoot({
|
|
629
|
-
global: true,
|
|
630
|
-
middleware: {
|
|
631
|
-
mount: true,
|
|
632
|
-
generateId: true,
|
|
633
|
-
idGenerator: (req: Request) =>
|
|
634
|
-
(req.headers['x-correlation-id'] as string) || uuidv4(),
|
|
635
|
-
},
|
|
636
|
-
}),
|
|
637
|
-
ContextModule, // Uses existing ClsModule
|
|
570
|
+
ContextModule, // Includes ClsModule internally
|
|
638
571
|
LoggerModule.forRoot(config, customTransports),
|
|
639
572
|
],
|
|
640
573
|
})
|
|
@@ -679,23 +612,11 @@ LOGGER_HTTP_ENDPOINT=https://logging-service.example.com/api/logs
|
|
|
679
612
|
|
|
680
613
|
**Via Module Configuration:**
|
|
681
614
|
```typescript
|
|
682
|
-
import { ClsModule } from 'nestjs-cls';
|
|
683
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
684
615
|
import { ContextModule, LoggerModule } from '@infineit/winston-logger';
|
|
685
616
|
|
|
686
617
|
@Module({
|
|
687
618
|
imports: [
|
|
688
|
-
//
|
|
689
|
-
ClsModule.forRoot({
|
|
690
|
-
global: true,
|
|
691
|
-
middleware: {
|
|
692
|
-
mount: true,
|
|
693
|
-
generateId: true,
|
|
694
|
-
idGenerator: (req: Request) =>
|
|
695
|
-
(req.headers['x-correlation-id'] as string) || uuidv4(),
|
|
696
|
-
},
|
|
697
|
-
}),
|
|
698
|
-
ContextModule, // Uses existing ClsModule
|
|
619
|
+
ContextModule, // Includes ClsModule internally
|
|
699
620
|
LoggerModule.forRoot({
|
|
700
621
|
// ... existing config
|
|
701
622
|
forwardToCentral: true,
|
|
@@ -843,7 +764,7 @@ LOGGER_KAFKA_TOPIC=project-logs-common
|
|
|
843
764
|
5. Check console errors: Forwarding errors are logged to `console.error` with message `"CentralLogForwarder forward error (swallowed): <error>"`
|
|
844
765
|
|
|
845
766
|
**Correlation ID Missing:**
|
|
846
|
-
- Ensure
|
|
767
|
+
- Ensure `ContextModule` is imported: `ContextModule` automatically configures `ClsModule` with `generateId: true`
|
|
847
768
|
- Ensure `ContextModule` is imported
|
|
848
769
|
- Check that original logs have `correlationId` field (if not, forwarded logs won't either)
|
|
849
770
|
|
|
@@ -972,35 +893,21 @@ Correlation ID is **optional** - `undefined` is valid:
|
|
|
972
893
|
|
|
973
894
|
### HTTP Context Setup
|
|
974
895
|
|
|
975
|
-
For HTTP services,
|
|
896
|
+
For HTTP services, `ContextModule` automatically configures CLS middleware. No additional setup required:
|
|
976
897
|
|
|
977
898
|
```typescript
|
|
978
|
-
import { ClsModule } from 'nestjs-cls';
|
|
979
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
980
899
|
import { ContextModule, LoggerModule } from '@infineit/winston-logger';
|
|
981
900
|
|
|
982
901
|
@Module({
|
|
983
902
|
imports: [
|
|
984
|
-
//
|
|
985
|
-
ClsModule.forRoot({
|
|
986
|
-
global: true,
|
|
987
|
-
middleware: {
|
|
988
|
-
mount: true,
|
|
989
|
-
generateId: true,
|
|
990
|
-
idGenerator: (req: Request) => {
|
|
991
|
-
// Use existing correlation ID from header, or generate new one
|
|
992
|
-
return (req.headers['x-correlation-id'] as string) || uuidv4();
|
|
993
|
-
},
|
|
994
|
-
},
|
|
995
|
-
}),
|
|
996
|
-
ContextModule, // Uses existing ClsModule configuration
|
|
903
|
+
ContextModule, // Automatically configures ClsModule with mount: true and generateId: true
|
|
997
904
|
LoggerModule.forRoot(),
|
|
998
905
|
],
|
|
999
906
|
})
|
|
1000
907
|
export class AppModule {}
|
|
1001
908
|
```
|
|
1002
909
|
|
|
1003
|
-
**Important:**
|
|
910
|
+
**Important:** `ContextModule` internally handles `ClsModule` configuration. Do NOT import `ClsModule` separately in your `AppModule`.
|
|
1004
911
|
|
|
1005
912
|
### CLS Context Boundaries and Edge Cases
|
|
1006
913
|
|
|
@@ -1170,30 +1077,7 @@ if (correlationId && validateCorrelationId(correlationId)) {
|
|
|
1170
1077
|
|
|
1171
1078
|
#### Validation in HTTP Middleware
|
|
1172
1079
|
|
|
1173
|
-
|
|
1174
|
-
import { ClsModule } from 'nestjs-cls';
|
|
1175
|
-
import { v4 as uuidv4, validate as uuidValidate } from 'uuid';
|
|
1176
|
-
|
|
1177
|
-
// ⚠️ CRITICAL: ClsModule MUST be imported BEFORE ContextModule in AppModule
|
|
1178
|
-
ClsModule.forRoot({
|
|
1179
|
-
global: true,
|
|
1180
|
-
middleware: {
|
|
1181
|
-
mount: true,
|
|
1182
|
-
generateId: true,
|
|
1183
|
-
idGenerator: (req: Request) => {
|
|
1184
|
-
const headerId = req.headers['x-correlation-id'] as string;
|
|
1185
|
-
|
|
1186
|
-
// Validate format
|
|
1187
|
-
if (headerId && uuidValidate(headerId)) {
|
|
1188
|
-
return headerId;
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
// Generate new one if invalid
|
|
1192
|
-
return uuidv4();
|
|
1193
|
-
},
|
|
1194
|
-
},
|
|
1195
|
-
})
|
|
1196
|
-
```
|
|
1080
|
+
**Note:** `ContextModule` automatically configures `ClsModule` with `mount: true` and `generateId: true`. Correlation IDs are automatically generated. If you need custom validation, you can access `ClsService` directly (exported by `ContextModule`) or use `ContextStorageService.setContextId()` in your middleware.
|
|
1197
1081
|
|
|
1198
1082
|
#### Validation in Kafka Consumers
|
|
1199
1083
|
|
|
@@ -1224,26 +1108,12 @@ async handleOrderCreated(message: OrderCreatedEvent) {
|
|
|
1224
1108
|
```typescript
|
|
1225
1109
|
import { Module, MiddlewareConsumer, NestModule } from '@nestjs/common';
|
|
1226
1110
|
import { ConfigModule } from '@nestjs/config';
|
|
1227
|
-
import { ClsModule } from 'nestjs-cls';
|
|
1228
|
-
import { v4 as uuidv4, validate as uuidValidate } from 'uuid';
|
|
1229
1111
|
import { ContextModule, LoggerModule } from '@infineit/winston-logger';
|
|
1230
1112
|
|
|
1231
1113
|
@Module({
|
|
1232
1114
|
imports: [
|
|
1233
1115
|
ConfigModule.forRoot({ isGlobal: true }),
|
|
1234
|
-
//
|
|
1235
|
-
ClsModule.forRoot({
|
|
1236
|
-
global: true,
|
|
1237
|
-
middleware: {
|
|
1238
|
-
mount: true,
|
|
1239
|
-
generateId: true,
|
|
1240
|
-
idGenerator: (req: Request) => {
|
|
1241
|
-
const headerId = req.headers['x-correlation-id'] as string;
|
|
1242
|
-
return (headerId && uuidValidate(headerId)) ? headerId : uuidv4();
|
|
1243
|
-
},
|
|
1244
|
-
},
|
|
1245
|
-
}),
|
|
1246
|
-
ContextModule, // Uses existing ClsModule configuration
|
|
1116
|
+
ContextModule, // Includes ClsModule internally with mount: true and generateId: true
|
|
1247
1117
|
LoggerModule.forRoot({
|
|
1248
1118
|
nodeEnv: process.env.NODE_ENV,
|
|
1249
1119
|
organization: 'sales',
|
|
@@ -1255,7 +1125,7 @@ import { ContextModule, LoggerModule } from '@infineit/winston-logger';
|
|
|
1255
1125
|
export class AppModule implements NestModule {
|
|
1256
1126
|
configure(consumer: MiddlewareConsumer) {
|
|
1257
1127
|
// Additional middleware can be added here
|
|
1258
|
-
//
|
|
1128
|
+
// ContextModule already configures ClsModule middleware internally
|
|
1259
1129
|
}
|
|
1260
1130
|
}
|
|
1261
1131
|
```
|
|
@@ -1679,25 +1549,11 @@ async createInvoice(@Body() data: CreateInvoiceDto, @Headers() headers: Headers)
|
|
|
1679
1549
|
**4. Common Service (app.module.ts):**
|
|
1680
1550
|
|
|
1681
1551
|
```typescript
|
|
1682
|
-
import { ClsModule } from 'nestjs-cls';
|
|
1683
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
1684
1552
|
import { ContextModule, LoggerModule } from '@infineit/winston-logger';
|
|
1685
1553
|
|
|
1686
1554
|
@Module({
|
|
1687
1555
|
imports: [
|
|
1688
|
-
//
|
|
1689
|
-
ClsModule.forRoot({
|
|
1690
|
-
global: true,
|
|
1691
|
-
middleware: {
|
|
1692
|
-
mount: true,
|
|
1693
|
-
generateId: true,
|
|
1694
|
-
idGenerator: (req: Request) => {
|
|
1695
|
-
// Extract from header (propagated from Document Service)
|
|
1696
|
-
return (req.headers['x-correlation-id'] as string) || uuidv4();
|
|
1697
|
-
},
|
|
1698
|
-
},
|
|
1699
|
-
}),
|
|
1700
|
-
ContextModule, // Uses existing ClsModule configuration
|
|
1556
|
+
ContextModule, // Includes ClsModule internally with mount: true and generateId: true
|
|
1701
1557
|
LoggerModule.forRoot(),
|
|
1702
1558
|
],
|
|
1703
1559
|
})
|
|
@@ -1862,23 +1718,11 @@ bootstrap();
|
|
|
1862
1718
|
```typescript
|
|
1863
1719
|
// ✅ CORRECT: Use LoggerService injection
|
|
1864
1720
|
import { NestFactory } from '@nestjs/core';
|
|
1865
|
-
import { ClsModule } from 'nestjs-cls';
|
|
1866
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
1867
1721
|
import { ContextModule, LoggerModule } from '@infineit/winston-logger';
|
|
1868
1722
|
|
|
1869
1723
|
@Module({
|
|
1870
1724
|
imports: [
|
|
1871
|
-
//
|
|
1872
|
-
ClsModule.forRoot({
|
|
1873
|
-
global: true,
|
|
1874
|
-
middleware: {
|
|
1875
|
-
mount: true,
|
|
1876
|
-
generateId: true,
|
|
1877
|
-
idGenerator: (req: Request) =>
|
|
1878
|
-
(req.headers['x-correlation-id'] as string) || uuidv4(),
|
|
1879
|
-
},
|
|
1880
|
-
}),
|
|
1881
|
-
ContextModule, // Uses existing ClsModule
|
|
1725
|
+
ContextModule, // ✅ Includes ClsModule internally with mount: true and generateId: true
|
|
1882
1726
|
LoggerModule.forRoot(),
|
|
1883
1727
|
],
|
|
1884
1728
|
})
|
|
@@ -1982,15 +1826,11 @@ export class MyService {
|
|
|
1982
1826
|
this.logger.info('message');
|
|
1983
1827
|
```
|
|
1984
1828
|
|
|
1985
|
-
5. **
|
|
1829
|
+
5. **Import ContextModule (automatically configures CLS middleware)**
|
|
1986
1830
|
```typescript
|
|
1987
|
-
// ✅
|
|
1988
|
-
ClsModule
|
|
1989
|
-
|
|
1990
|
-
mount: true,
|
|
1991
|
-
generateId: true,
|
|
1992
|
-
},
|
|
1993
|
-
}),
|
|
1831
|
+
// ✅ ContextModule automatically configures ClsModule with mount: true and generateId: true
|
|
1832
|
+
// No need to import ClsModule separately
|
|
1833
|
+
ContextModule,
|
|
1994
1834
|
```
|
|
1995
1835
|
|
|
1996
1836
|
### Reassurance: Nothing Breaks
|
|
@@ -2036,24 +1876,12 @@ async function bootstrap() {
|
|
|
2036
1876
|
**After (Current)**:
|
|
2037
1877
|
```typescript
|
|
2038
1878
|
import { NestFactory } from '@nestjs/core';
|
|
2039
|
-
import { ClsModule } from 'nestjs-cls';
|
|
2040
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
2041
1879
|
import { ContextModule, LoggerModule } from '@infineit/winston-logger';
|
|
2042
1880
|
|
|
2043
1881
|
@Module({
|
|
2044
1882
|
imports: [
|
|
2045
|
-
//
|
|
2046
|
-
|
|
2047
|
-
global: true,
|
|
2048
|
-
middleware: {
|
|
2049
|
-
mount: true,
|
|
2050
|
-
generateId: true,
|
|
2051
|
-
idGenerator: (req: Request) =>
|
|
2052
|
-
(req.headers['x-correlation-id'] as string) || uuidv4(),
|
|
2053
|
-
},
|
|
2054
|
-
}),
|
|
2055
|
-
ContextModule, // ✅ Uses existing ClsModule
|
|
2056
|
-
LoggerModule.forRoot(), // ✅ Add
|
|
1883
|
+
ContextModule, // ✅ Includes ClsModule internally with mount: true and generateId: true
|
|
1884
|
+
LoggerModule.forRoot(), // ✅ Configure logger
|
|
2057
1885
|
],
|
|
2058
1886
|
})
|
|
2059
1887
|
export class AppModule {}
|
|
@@ -2070,9 +1898,10 @@ async function bootstrap() {
|
|
|
2070
1898
|
|
|
2071
1899
|
If you encounter issues during migration:
|
|
2072
1900
|
|
|
2073
|
-
1. **Check module imports**: Ensure `
|
|
2074
|
-
2. **
|
|
2075
|
-
3. **Check
|
|
1901
|
+
1. **Check module imports**: Ensure `ContextModule` and `LoggerModule.forRoot()` are in your `AppModule`
|
|
1902
|
+
2. **Do NOT import ClsModule**: `ContextModule` handles `ClsModule` internally - do NOT import it separately
|
|
1903
|
+
3. **Check injection**: Ensure `LoggerService` is injected via constructor
|
|
1904
|
+
4. **Review examples**: See the "Usage in Different Contexts" section above
|
|
2076
1905
|
4. **Check injection**: Ensure `LoggerService` is injected via constructor
|
|
2077
1906
|
5. **Review examples**: See the "Usage in Different Contexts" section above
|
|
2078
1907
|
|
|
@@ -2235,24 +2064,12 @@ async log(...) { // ❌
|
|
|
2235
2064
|
```typescript
|
|
2236
2065
|
import { Module } from '@nestjs/common';
|
|
2237
2066
|
import { ConfigModule } from '@nestjs/config';
|
|
2238
|
-
import { ClsModule } from 'nestjs-cls';
|
|
2239
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
2240
2067
|
import { ContextModule, LoggerModule } from '@infineit/winston-logger';
|
|
2241
2068
|
|
|
2242
2069
|
@Module({
|
|
2243
2070
|
imports: [
|
|
2244
2071
|
ConfigModule.forRoot({ isGlobal: true }),
|
|
2245
|
-
//
|
|
2246
|
-
ClsModule.forRoot({
|
|
2247
|
-
global: true,
|
|
2248
|
-
middleware: {
|
|
2249
|
-
mount: true,
|
|
2250
|
-
generateId: true,
|
|
2251
|
-
idGenerator: (req: Request) =>
|
|
2252
|
-
(req.headers['x-correlation-id'] as string) || uuidv4(),
|
|
2253
|
-
},
|
|
2254
|
-
}),
|
|
2255
|
-
ContextModule, // Uses existing ClsModule configuration
|
|
2072
|
+
ContextModule, // Includes ClsModule internally with mount: true and generateId: true
|
|
2256
2073
|
LoggerModule.forRoot({
|
|
2257
2074
|
nodeEnv: process.env.NODE_ENV,
|
|
2258
2075
|
organization: 'my-org',
|
|
@@ -11,6 +11,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ContextModule = void 0;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
14
15
|
const contextStorageService_1 = require("../../../context/domain/interfaces/contextStorageService");
|
|
15
16
|
const nestjsClsContextStorageService_1 = __importDefault(require("../../../context/infrastructure/nestjs-cls/nestjsClsContextStorageService"));
|
|
16
17
|
let ContextModule = class ContextModule {
|
|
@@ -19,7 +20,15 @@ exports.ContextModule = ContextModule;
|
|
|
19
20
|
exports.ContextModule = ContextModule = __decorate([
|
|
20
21
|
(0, common_1.Global)(),
|
|
21
22
|
(0, common_1.Module)({
|
|
22
|
-
imports: [
|
|
23
|
+
imports: [
|
|
24
|
+
nestjs_cls_1.ClsModule.forRoot({
|
|
25
|
+
global: true,
|
|
26
|
+
middleware: {
|
|
27
|
+
mount: false,
|
|
28
|
+
generateId: false,
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
23
32
|
controllers: [],
|
|
24
33
|
providers: [
|
|
25
34
|
{
|
|
@@ -27,7 +36,7 @@ exports.ContextModule = ContextModule = __decorate([
|
|
|
27
36
|
useClass: nestjsClsContextStorageService_1.default,
|
|
28
37
|
},
|
|
29
38
|
],
|
|
30
|
-
exports: [contextStorageService_1.ContextStorageServiceKey],
|
|
39
|
+
exports: [contextStorageService_1.ContextStorageServiceKey, nestjs_cls_1.ClsModule],
|
|
31
40
|
})
|
|
32
41
|
], ContextModule);
|
|
33
42
|
//# sourceMappingURL=contextModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextModule.js","sourceRoot":"","sources":["../../../../../libs/src/context/infrastructure/nestjs/contextModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAgD;
|
|
1
|
+
{"version":3,"file":"contextModule.js","sourceRoot":"","sources":["../../../../../libs/src/context/infrastructure/nestjs/contextModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAgD;AAEhD,2CAAuC;AAEvC,oGAAoG;AACpG,+IAAuH;AAuDhH,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IAvBzB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACJ,OAAO,EAAE;YAIL,sBAAS,CAAC,OAAO,CAAC;gBACd,MAAM,EAAE,IAAI;gBACZ,UAAU,EAAE;oBACR,KAAK,EAAE,KAAK;oBACZ,UAAU,EAAE,KAAK;iBACpB;aACJ,CAAC;SACL;QACD,WAAW,EAAE,EAAE;QACf,SAAS,EAAE;YACP;gBACI,OAAO,EAAE,gDAAwB;gBACjC,QAAQ,EAAE,wCAA8B;aAC3C;SACJ;QACD,OAAO,EAAE,CAAC,gDAAwB,EAAE,sBAAS,CAAC;KACjD,CAAC;GACW,aAAa,CAAG"}
|