@vritti/api-sdk 0.0.8 → 0.0.9
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 +267 -0
- package/dist/index.cjs +907 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +406 -3
- package/dist/index.d.ts +406 -3
- package/dist/index.js +894 -2
- package/dist/index.js.map +1 -1
- package/package.json +9 -5
package/dist/index.js
CHANGED
|
@@ -1942,7 +1942,9 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
1942
1942
|
detail = exceptionResponse;
|
|
1943
1943
|
}
|
|
1944
1944
|
} else {
|
|
1945
|
-
|
|
1945
|
+
const errorMessage = exception instanceof Error ? exception.message : "Unknown error";
|
|
1946
|
+
const stack = exception instanceof Error ? exception.stack : void 0;
|
|
1947
|
+
this.logger.error(`Unexpected error: ${errorMessage}`, stack);
|
|
1946
1948
|
errors = [
|
|
1947
1949
|
{
|
|
1948
1950
|
message: "An unexpected error occurred"
|
|
@@ -2345,19 +2347,903 @@ var BadGatewayException = class extends BaseFieldException {
|
|
|
2345
2347
|
}
|
|
2346
2348
|
}
|
|
2347
2349
|
};
|
|
2350
|
+
|
|
2351
|
+
// src/logger/logger.module.ts
|
|
2352
|
+
import { Global as Global4, Module as Module5, Logger as Logger11 } from "@nestjs/common";
|
|
2353
|
+
|
|
2354
|
+
// src/logger/services/logger.service.ts
|
|
2355
|
+
import { Injectable as Injectable9, Logger as Logger10, Optional } from "@nestjs/common";
|
|
2356
|
+
import { createLogger, format, transports } from "winston";
|
|
2357
|
+
import DailyRotateFile from "winston-daily-rotate-file";
|
|
2358
|
+
|
|
2359
|
+
// src/logger/utils/index.ts
|
|
2360
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
2361
|
+
import { randomUUID } from "crypto";
|
|
2362
|
+
var correlationStorage = new AsyncLocalStorage();
|
|
2363
|
+
function getCorrelationContext() {
|
|
2364
|
+
return correlationStorage.getStore();
|
|
2365
|
+
}
|
|
2366
|
+
__name(getCorrelationContext, "getCorrelationContext");
|
|
2367
|
+
function runWithCorrelationContext(context, callback) {
|
|
2368
|
+
return correlationStorage.run(context, callback);
|
|
2369
|
+
}
|
|
2370
|
+
__name(runWithCorrelationContext, "runWithCorrelationContext");
|
|
2371
|
+
function updateCorrelationContext(updates) {
|
|
2372
|
+
const context = correlationStorage.getStore();
|
|
2373
|
+
if (context) {
|
|
2374
|
+
Object.assign(context, updates);
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
__name(updateCorrelationContext, "updateCorrelationContext");
|
|
2378
|
+
var DEFAULT_CORRELATION_HEADER = "x-correlation-id";
|
|
2379
|
+
function generateCorrelationId() {
|
|
2380
|
+
return randomUUID();
|
|
2381
|
+
}
|
|
2382
|
+
__name(generateCorrelationId, "generateCorrelationId");
|
|
2383
|
+
function addCorrelationIdToResponse(reply, correlationId, headerName = DEFAULT_CORRELATION_HEADER) {
|
|
2384
|
+
if (typeof reply.header === "function") {
|
|
2385
|
+
reply.header(headerName, correlationId);
|
|
2386
|
+
} else if (reply.raw && typeof reply.raw.setHeader === "function") {
|
|
2387
|
+
reply.raw.setHeader(headerName, correlationId);
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
__name(addCorrelationIdToResponse, "addCorrelationIdToResponse");
|
|
2391
|
+
|
|
2392
|
+
// src/logger/services/logger.service.ts
|
|
2393
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2394
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2395
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2396
|
+
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;
|
|
2397
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2398
|
+
}
|
|
2399
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2400
|
+
function _ts_metadata8(k, v) {
|
|
2401
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2402
|
+
}
|
|
2403
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2404
|
+
function _ts_param4(paramIndex, decorator) {
|
|
2405
|
+
return function(target, key) {
|
|
2406
|
+
decorator(target, key, paramIndex);
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
__name(_ts_param4, "_ts_param");
|
|
2410
|
+
var LoggerService2 = class _LoggerService {
|
|
2411
|
+
static {
|
|
2412
|
+
__name(this, "LoggerService");
|
|
2413
|
+
}
|
|
2414
|
+
defaultLogger;
|
|
2415
|
+
activeLogger;
|
|
2416
|
+
options;
|
|
2417
|
+
context;
|
|
2418
|
+
constructor(options = {}, defaultLogger) {
|
|
2419
|
+
this.defaultLogger = defaultLogger;
|
|
2420
|
+
this.options = options;
|
|
2421
|
+
const provider = options.provider ?? "winston";
|
|
2422
|
+
if (provider === "default") {
|
|
2423
|
+
if (!this.defaultLogger) {
|
|
2424
|
+
throw new Error("LoggerService: Default Logger not provided");
|
|
2425
|
+
}
|
|
2426
|
+
this.activeLogger = this.defaultLogger;
|
|
2427
|
+
} else {
|
|
2428
|
+
this.activeLogger = this.createWinstonLogger(options);
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
/**
|
|
2432
|
+
* Creates a Winston logger instance with inline configuration.
|
|
2433
|
+
* Consolidates winston-config.factory.ts logic.
|
|
2434
|
+
*/
|
|
2435
|
+
createWinstonLogger(opts) {
|
|
2436
|
+
const level = opts.level ?? "debug";
|
|
2437
|
+
const logFormat = opts.format ?? "text";
|
|
2438
|
+
const baseFormatters = [
|
|
2439
|
+
format.timestamp({
|
|
2440
|
+
format: "YYYY-MM-DDTHH:mm:ss.SSSZ"
|
|
2441
|
+
}),
|
|
2442
|
+
format.errors({
|
|
2443
|
+
stack: true
|
|
2444
|
+
})
|
|
2445
|
+
];
|
|
2446
|
+
const consoleTransport = logFormat === "json" ? new transports.Console({
|
|
2447
|
+
level,
|
|
2448
|
+
format: format.combine(...baseFormatters, format.json())
|
|
2449
|
+
}) : new transports.Console({
|
|
2450
|
+
level,
|
|
2451
|
+
format: format.combine(...baseFormatters, format.printf((info) => {
|
|
2452
|
+
const { timestamp, level: level2, message, context, correlationId, trace } = info;
|
|
2453
|
+
const parts = [
|
|
2454
|
+
timestamp,
|
|
2455
|
+
level2.toUpperCase().padEnd(7),
|
|
2456
|
+
correlationId ? `[${correlationId.toString().slice(-6)}]` : "",
|
|
2457
|
+
context ? `[${context}]` : "",
|
|
2458
|
+
message
|
|
2459
|
+
].filter(Boolean);
|
|
2460
|
+
let output = parts.join(" ");
|
|
2461
|
+
if (trace) {
|
|
2462
|
+
output += "\n" + trace;
|
|
2463
|
+
}
|
|
2464
|
+
return output;
|
|
2465
|
+
}), format.colorize({
|
|
2466
|
+
all: true
|
|
2467
|
+
}))
|
|
2468
|
+
});
|
|
2469
|
+
const winstonTransports = [
|
|
2470
|
+
consoleTransport
|
|
2471
|
+
];
|
|
2472
|
+
if (opts.enableFileLogger) {
|
|
2473
|
+
const filePath = opts.filePath ?? "./logs";
|
|
2474
|
+
const maxFiles = opts.maxFiles ?? "14d";
|
|
2475
|
+
winstonTransports.push(new DailyRotateFile({
|
|
2476
|
+
level,
|
|
2477
|
+
filename: `${filePath}/%DATE%-combined.log`,
|
|
2478
|
+
datePattern: "YYYY-MM-DD",
|
|
2479
|
+
maxSize: "20m",
|
|
2480
|
+
maxFiles,
|
|
2481
|
+
format: format.combine(format.timestamp(), format.json())
|
|
2482
|
+
}), new DailyRotateFile({
|
|
2483
|
+
level: "error",
|
|
2484
|
+
filename: `${filePath}/%DATE%-error.log`,
|
|
2485
|
+
datePattern: "YYYY-MM-DD",
|
|
2486
|
+
maxSize: "20m",
|
|
2487
|
+
maxFiles,
|
|
2488
|
+
format: format.combine(format.timestamp(), format.json())
|
|
2489
|
+
}));
|
|
2490
|
+
}
|
|
2491
|
+
const config = {
|
|
2492
|
+
level,
|
|
2493
|
+
transports: winstonTransports,
|
|
2494
|
+
exitOnError: false
|
|
2495
|
+
};
|
|
2496
|
+
if (opts.defaultMeta || opts.appName) {
|
|
2497
|
+
config.defaultMeta = {
|
|
2498
|
+
...opts.defaultMeta,
|
|
2499
|
+
appName: opts.appName,
|
|
2500
|
+
environment: opts.environment
|
|
2501
|
+
};
|
|
2502
|
+
}
|
|
2503
|
+
return createLogger(config);
|
|
2504
|
+
}
|
|
2505
|
+
// NestJS LoggerService interface methods
|
|
2506
|
+
log(message, context) {
|
|
2507
|
+
this._log("log", message, context);
|
|
2508
|
+
}
|
|
2509
|
+
error(message, trace, context) {
|
|
2510
|
+
this._log("error", message, context, trace);
|
|
2511
|
+
}
|
|
2512
|
+
warn(message, context) {
|
|
2513
|
+
this._log("warn", message, context);
|
|
2514
|
+
}
|
|
2515
|
+
debug(message, context) {
|
|
2516
|
+
this._log("debug", message, context);
|
|
2517
|
+
}
|
|
2518
|
+
verbose(message, context) {
|
|
2519
|
+
this._log("verbose", message, context);
|
|
2520
|
+
}
|
|
2521
|
+
setContext(context) {
|
|
2522
|
+
this.context = context;
|
|
2523
|
+
}
|
|
2524
|
+
/**
|
|
2525
|
+
* Unified internal logging method that handles both Winston and NestJS Logger.
|
|
2526
|
+
*/
|
|
2527
|
+
_log(level, message, context, trace) {
|
|
2528
|
+
const ctx = context ?? this.context;
|
|
2529
|
+
if ("format" in this.activeLogger && "transports" in this.activeLogger) {
|
|
2530
|
+
const winstonLogger = this.activeLogger;
|
|
2531
|
+
const winstonLevel = level === "log" ? "info" : level;
|
|
2532
|
+
const formattedMessage = this.formatMessage(message);
|
|
2533
|
+
const metadata = this.enrichMetadata({}, ctx, trace);
|
|
2534
|
+
winstonLogger.log({
|
|
2535
|
+
level: winstonLevel,
|
|
2536
|
+
message: formattedMessage,
|
|
2537
|
+
...metadata
|
|
2538
|
+
});
|
|
2539
|
+
} else {
|
|
2540
|
+
const nestLogger = this.activeLogger;
|
|
2541
|
+
if (level === "error" && trace) {
|
|
2542
|
+
ctx ? nestLogger.error(message, trace, ctx) : nestLogger.error(message, trace);
|
|
2543
|
+
} else if (level === "log") {
|
|
2544
|
+
ctx ? nestLogger.log(message, ctx) : nestLogger.log(message);
|
|
2545
|
+
} else if (level === "warn") {
|
|
2546
|
+
ctx ? nestLogger.warn(message, ctx) : nestLogger.warn(message);
|
|
2547
|
+
} else if (level === "debug" && nestLogger.debug) {
|
|
2548
|
+
ctx ? nestLogger.debug(message, ctx) : nestLogger.debug(message);
|
|
2549
|
+
} else if (level === "verbose" && nestLogger.verbose) {
|
|
2550
|
+
ctx ? nestLogger.verbose(message, ctx) : nestLogger.verbose(message);
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
/**
|
|
2555
|
+
* Logs with custom metadata (Winston only).
|
|
2556
|
+
*/
|
|
2557
|
+
logWithMetadata(level, message, metadata, context) {
|
|
2558
|
+
const ctx = context ?? this.context;
|
|
2559
|
+
if ("format" in this.activeLogger && "transports" in this.activeLogger) {
|
|
2560
|
+
const winstonLogger = this.activeLogger;
|
|
2561
|
+
const winstonLevel = level === "log" ? "info" : level;
|
|
2562
|
+
winstonLogger.log({
|
|
2563
|
+
level: winstonLevel,
|
|
2564
|
+
message: this.formatMessage(message),
|
|
2565
|
+
...metadata
|
|
2566
|
+
});
|
|
2567
|
+
} else {
|
|
2568
|
+
const messageWithMeta = metadata ? `${message} ${JSON.stringify(metadata)}` : message;
|
|
2569
|
+
this[level](messageWithMeta, ctx);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
formatMessage(message) {
|
|
2573
|
+
if (message instanceof Error) return message.message;
|
|
2574
|
+
if (typeof message === "object" && message !== null) {
|
|
2575
|
+
try {
|
|
2576
|
+
return JSON.stringify(message);
|
|
2577
|
+
} catch {
|
|
2578
|
+
return String(message);
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
return String(message);
|
|
2582
|
+
}
|
|
2583
|
+
/**
|
|
2584
|
+
* Enriches metadata with correlation context from AsyncLocalStorage.
|
|
2585
|
+
* Inline from winston-logger.service.ts
|
|
2586
|
+
*/
|
|
2587
|
+
enrichMetadata(metadata = {}, context, trace) {
|
|
2588
|
+
const enriched = {
|
|
2589
|
+
...metadata
|
|
2590
|
+
};
|
|
2591
|
+
if (context) enriched.context = context;
|
|
2592
|
+
const correlationContext = getCorrelationContext();
|
|
2593
|
+
if (correlationContext) {
|
|
2594
|
+
if (correlationContext.correlationId) enriched.correlationId = correlationContext.correlationId;
|
|
2595
|
+
for (const [key, value] of Object.entries(correlationContext)) {
|
|
2596
|
+
if (key !== "correlationId") {
|
|
2597
|
+
enriched[key] = value;
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
if (trace) enriched.trace = trace;
|
|
2602
|
+
return enriched;
|
|
2603
|
+
}
|
|
2604
|
+
child(context) {
|
|
2605
|
+
const childLogger = new _LoggerService(this.options, this.defaultLogger);
|
|
2606
|
+
childLogger.setContext(context);
|
|
2607
|
+
return childLogger;
|
|
2608
|
+
}
|
|
2609
|
+
};
|
|
2610
|
+
LoggerService2 = _ts_decorate14([
|
|
2611
|
+
Injectable9(),
|
|
2612
|
+
_ts_param4(0, Optional()),
|
|
2613
|
+
_ts_param4(1, Optional()),
|
|
2614
|
+
_ts_metadata8("design:type", Function),
|
|
2615
|
+
_ts_metadata8("design:paramtypes", [
|
|
2616
|
+
typeof LoggerModuleOptions === "undefined" ? Object : LoggerModuleOptions,
|
|
2617
|
+
typeof Logger10 === "undefined" ? Object : Logger10
|
|
2618
|
+
])
|
|
2619
|
+
], LoggerService2);
|
|
2620
|
+
|
|
2621
|
+
// src/logger/middleware/correlation-id.middleware.ts
|
|
2622
|
+
import { Injectable as Injectable10 } from "@nestjs/common";
|
|
2623
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2624
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2625
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2626
|
+
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;
|
|
2627
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2628
|
+
}
|
|
2629
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2630
|
+
function _ts_metadata9(k, v) {
|
|
2631
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2632
|
+
}
|
|
2633
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2634
|
+
var CorrelationIdMiddleware = class {
|
|
2635
|
+
static {
|
|
2636
|
+
__name(this, "CorrelationIdMiddleware");
|
|
2637
|
+
}
|
|
2638
|
+
includeInResponse;
|
|
2639
|
+
responseHeader;
|
|
2640
|
+
constructor(options = {}) {
|
|
2641
|
+
this.includeInResponse = options.includeInResponse ?? true;
|
|
2642
|
+
this.responseHeader = options.responseHeader ?? DEFAULT_CORRELATION_HEADER;
|
|
2643
|
+
}
|
|
2644
|
+
/**
|
|
2645
|
+
* Middleware handler for processing requests.
|
|
2646
|
+
*/
|
|
2647
|
+
use(req, reply, next) {
|
|
2648
|
+
const correlationId = generateCorrelationId();
|
|
2649
|
+
if (this.includeInResponse) {
|
|
2650
|
+
addCorrelationIdToResponse(reply, correlationId, this.responseHeader);
|
|
2651
|
+
}
|
|
2652
|
+
runWithCorrelationContext({
|
|
2653
|
+
correlationId
|
|
2654
|
+
}, () => {
|
|
2655
|
+
next();
|
|
2656
|
+
});
|
|
2657
|
+
}
|
|
2658
|
+
/**
|
|
2659
|
+
* Fastify hook handler for onRequest.
|
|
2660
|
+
* This is an async function that returns a Promise, ensuring the AsyncLocalStorage
|
|
2661
|
+
* context persists throughout the entire request lifecycle.
|
|
2662
|
+
*/
|
|
2663
|
+
async onRequest(req, reply) {
|
|
2664
|
+
const correlationId = generateCorrelationId();
|
|
2665
|
+
if (this.includeInResponse) {
|
|
2666
|
+
addCorrelationIdToResponse(reply, correlationId, this.responseHeader);
|
|
2667
|
+
}
|
|
2668
|
+
const store = correlationStorage.getStore();
|
|
2669
|
+
if (!store) {
|
|
2670
|
+
correlationStorage.enterWith({
|
|
2671
|
+
correlationId
|
|
2672
|
+
});
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
};
|
|
2676
|
+
CorrelationIdMiddleware = _ts_decorate15([
|
|
2677
|
+
Injectable10(),
|
|
2678
|
+
_ts_metadata9("design:type", Function),
|
|
2679
|
+
_ts_metadata9("design:paramtypes", [
|
|
2680
|
+
typeof CorrelationIdMiddlewareOptions === "undefined" ? Object : CorrelationIdMiddlewareOptions
|
|
2681
|
+
])
|
|
2682
|
+
], CorrelationIdMiddleware);
|
|
2683
|
+
|
|
2684
|
+
// src/logger/interceptors/http-logger.interceptor.ts
|
|
2685
|
+
import { Injectable as Injectable11, Optional as Optional2 } from "@nestjs/common";
|
|
2686
|
+
import { tap as tap2, catchError } from "rxjs/operators";
|
|
2687
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2688
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2689
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2690
|
+
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;
|
|
2691
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2692
|
+
}
|
|
2693
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2694
|
+
function _ts_metadata10(k, v) {
|
|
2695
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2696
|
+
}
|
|
2697
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2698
|
+
function _ts_param5(paramIndex, decorator) {
|
|
2699
|
+
return function(target, key) {
|
|
2700
|
+
decorator(target, key, paramIndex);
|
|
2701
|
+
};
|
|
2702
|
+
}
|
|
2703
|
+
__name(_ts_param5, "_ts_param");
|
|
2704
|
+
var HttpLoggerInterceptor = class {
|
|
2705
|
+
static {
|
|
2706
|
+
__name(this, "HttpLoggerInterceptor");
|
|
2707
|
+
}
|
|
2708
|
+
logger;
|
|
2709
|
+
enableRequestLog;
|
|
2710
|
+
enableResponseLog;
|
|
2711
|
+
slowRequestThreshold;
|
|
2712
|
+
constructor(logger, options) {
|
|
2713
|
+
this.logger = logger;
|
|
2714
|
+
this.enableRequestLog = options?.enableRequestLog ?? true;
|
|
2715
|
+
this.enableResponseLog = options?.enableResponseLog ?? true;
|
|
2716
|
+
this.slowRequestThreshold = options?.slowRequestThreshold ?? 3e3;
|
|
2717
|
+
}
|
|
2718
|
+
intercept(context, next) {
|
|
2719
|
+
if (context.getType() !== "http") {
|
|
2720
|
+
return next.handle();
|
|
2721
|
+
}
|
|
2722
|
+
const httpContext = context.switchToHttp();
|
|
2723
|
+
const request = httpContext.getRequest();
|
|
2724
|
+
const response = httpContext.getResponse();
|
|
2725
|
+
const startTime = Date.now();
|
|
2726
|
+
if (this.enableRequestLog) {
|
|
2727
|
+
this.logRequest(request);
|
|
2728
|
+
}
|
|
2729
|
+
return next.handle().pipe(tap2(() => {
|
|
2730
|
+
if (this.enableResponseLog) {
|
|
2731
|
+
const duration = Date.now() - startTime;
|
|
2732
|
+
this.logResponse(request, response, duration);
|
|
2733
|
+
}
|
|
2734
|
+
}), catchError((error) => {
|
|
2735
|
+
const duration = Date.now() - startTime;
|
|
2736
|
+
this.logError(request, response, duration, error);
|
|
2737
|
+
throw error;
|
|
2738
|
+
}));
|
|
2739
|
+
}
|
|
2740
|
+
logRequest(request) {
|
|
2741
|
+
try {
|
|
2742
|
+
const correlationContext = getCorrelationContext();
|
|
2743
|
+
const metadata = {
|
|
2744
|
+
type: "http_request",
|
|
2745
|
+
method: request.method,
|
|
2746
|
+
url: request.url,
|
|
2747
|
+
correlationId: correlationContext?.correlationId,
|
|
2748
|
+
ip: request.ip,
|
|
2749
|
+
userAgent: request.headers["user-agent"]
|
|
2750
|
+
};
|
|
2751
|
+
this.logger.logWithMetadata("log", `Incoming ${request.method} ${request.url}`, metadata);
|
|
2752
|
+
} catch (error) {
|
|
2753
|
+
this.logger.error("Failed to log HTTP request", error.stack);
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
logResponse(request, response, duration) {
|
|
2757
|
+
try {
|
|
2758
|
+
const correlationContext = getCorrelationContext();
|
|
2759
|
+
const statusCode = response.statusCode;
|
|
2760
|
+
const logLevel = statusCode >= 500 ? "error" : statusCode >= 400 ? "warn" : "log";
|
|
2761
|
+
const metadata = {
|
|
2762
|
+
type: "http_response",
|
|
2763
|
+
method: request.method,
|
|
2764
|
+
url: request.url,
|
|
2765
|
+
statusCode,
|
|
2766
|
+
duration,
|
|
2767
|
+
correlationId: correlationContext?.correlationId
|
|
2768
|
+
};
|
|
2769
|
+
if (duration > this.slowRequestThreshold) {
|
|
2770
|
+
metadata.slowRequest = true;
|
|
2771
|
+
}
|
|
2772
|
+
const message = metadata.slowRequest ? `SLOW ${request.method} ${request.url} ${statusCode} - ${duration}ms` : `${request.method} ${request.url} ${statusCode} - ${duration}ms`;
|
|
2773
|
+
this.logger.logWithMetadata(logLevel, message, metadata);
|
|
2774
|
+
} catch (error) {
|
|
2775
|
+
this.logger.error("Failed to log HTTP response", error.stack);
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
logError(request, response, duration, error) {
|
|
2779
|
+
try {
|
|
2780
|
+
const correlationContext = getCorrelationContext();
|
|
2781
|
+
const statusCode = response.statusCode || 500;
|
|
2782
|
+
const metadata = {
|
|
2783
|
+
type: "http_error",
|
|
2784
|
+
method: request.method,
|
|
2785
|
+
url: request.url,
|
|
2786
|
+
statusCode,
|
|
2787
|
+
duration,
|
|
2788
|
+
correlationId: correlationContext?.correlationId,
|
|
2789
|
+
errorName: error?.name || "Error",
|
|
2790
|
+
errorMessage: error?.message || "Unknown error"
|
|
2791
|
+
};
|
|
2792
|
+
if (error?.stack) {
|
|
2793
|
+
metadata.trace = error.stack;
|
|
2794
|
+
}
|
|
2795
|
+
if (error?.response) {
|
|
2796
|
+
metadata.errorDetails = error.response;
|
|
2797
|
+
}
|
|
2798
|
+
const message = `ERROR ${request.method} ${request.url} ${statusCode} - ${error?.message || "Unknown error"}`;
|
|
2799
|
+
this.logger.logWithMetadata("error", message, metadata);
|
|
2800
|
+
} catch (loggingError) {
|
|
2801
|
+
this.logger.error("Failed to log HTTP error", loggingError.stack);
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
};
|
|
2805
|
+
HttpLoggerInterceptor = _ts_decorate16([
|
|
2806
|
+
Injectable11(),
|
|
2807
|
+
_ts_param5(1, Optional2()),
|
|
2808
|
+
_ts_metadata10("design:type", Function),
|
|
2809
|
+
_ts_metadata10("design:paramtypes", [
|
|
2810
|
+
typeof LoggerService === "undefined" ? Object : LoggerService,
|
|
2811
|
+
typeof HttpLoggerOptions === "undefined" ? Object : HttpLoggerOptions
|
|
2812
|
+
])
|
|
2813
|
+
], HttpLoggerInterceptor);
|
|
2814
|
+
|
|
2815
|
+
// src/logger/logger.module.ts
|
|
2816
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2817
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2818
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2819
|
+
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;
|
|
2820
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2821
|
+
}
|
|
2822
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2823
|
+
var LOGGER_MODULE_OPTIONS = Symbol("LOGGER_MODULE_OPTIONS");
|
|
2824
|
+
var DEFAULT_LOGGER_OPTIONS = {
|
|
2825
|
+
provider: "winston",
|
|
2826
|
+
enableCorrelationId: true,
|
|
2827
|
+
enableHttpLogger: true,
|
|
2828
|
+
filePath: "./logs",
|
|
2829
|
+
maxFiles: "14d"
|
|
2830
|
+
};
|
|
2831
|
+
var ENVIRONMENT_PRESETS = {
|
|
2832
|
+
/**
|
|
2833
|
+
* Development preset - maximum verbosity for local development
|
|
2834
|
+
*/
|
|
2835
|
+
development: {
|
|
2836
|
+
provider: "winston",
|
|
2837
|
+
level: "debug",
|
|
2838
|
+
format: "text",
|
|
2839
|
+
enableFileLogger: false,
|
|
2840
|
+
enableCorrelationId: true,
|
|
2841
|
+
enableHttpLogger: true,
|
|
2842
|
+
httpLogger: {
|
|
2843
|
+
enableRequestLog: true,
|
|
2844
|
+
enableResponseLog: true,
|
|
2845
|
+
slowRequestThreshold: 1e3
|
|
2846
|
+
}
|
|
2847
|
+
},
|
|
2848
|
+
/**
|
|
2849
|
+
* Staging preset - moderate verbosity with file logging
|
|
2850
|
+
*/
|
|
2851
|
+
staging: {
|
|
2852
|
+
provider: "winston",
|
|
2853
|
+
level: "log",
|
|
2854
|
+
format: "json",
|
|
2855
|
+
enableFileLogger: true,
|
|
2856
|
+
enableCorrelationId: true,
|
|
2857
|
+
enableHttpLogger: true,
|
|
2858
|
+
httpLogger: {
|
|
2859
|
+
enableRequestLog: true,
|
|
2860
|
+
enableResponseLog: true,
|
|
2861
|
+
slowRequestThreshold: 3e3
|
|
2862
|
+
}
|
|
2863
|
+
},
|
|
2864
|
+
/**
|
|
2865
|
+
* Production preset - minimal verbosity with all safety features enabled
|
|
2866
|
+
*/
|
|
2867
|
+
production: {
|
|
2868
|
+
provider: "winston",
|
|
2869
|
+
level: "warn",
|
|
2870
|
+
format: "json",
|
|
2871
|
+
enableFileLogger: true,
|
|
2872
|
+
enableCorrelationId: true,
|
|
2873
|
+
enableHttpLogger: true,
|
|
2874
|
+
httpLogger: {
|
|
2875
|
+
enableRequestLog: false,
|
|
2876
|
+
enableResponseLog: true,
|
|
2877
|
+
slowRequestThreshold: 5e3
|
|
2878
|
+
}
|
|
2879
|
+
},
|
|
2880
|
+
/**
|
|
2881
|
+
* Test preset - errors only, minimal features for faster test execution
|
|
2882
|
+
*/
|
|
2883
|
+
test: {
|
|
2884
|
+
provider: "winston",
|
|
2885
|
+
level: "error",
|
|
2886
|
+
format: "json",
|
|
2887
|
+
enableFileLogger: false,
|
|
2888
|
+
enableCorrelationId: false,
|
|
2889
|
+
enableHttpLogger: false
|
|
2890
|
+
}
|
|
2891
|
+
};
|
|
2892
|
+
function mergeWithDefaults(options = {}) {
|
|
2893
|
+
const preset = options.environment ? ENVIRONMENT_PRESETS[options.environment] ?? ENVIRONMENT_PRESETS.development : ENVIRONMENT_PRESETS.development;
|
|
2894
|
+
const filteredOptions = Object.fromEntries(Object.entries(options).filter(([_, value]) => value !== void 0));
|
|
2895
|
+
if (filteredOptions.httpLogger && preset?.httpLogger) {
|
|
2896
|
+
filteredOptions.httpLogger = {
|
|
2897
|
+
...preset.httpLogger,
|
|
2898
|
+
...Object.fromEntries(Object.entries(filteredOptions.httpLogger).filter(([_, value]) => value !== void 0))
|
|
2899
|
+
};
|
|
2900
|
+
}
|
|
2901
|
+
const merged = {
|
|
2902
|
+
...DEFAULT_LOGGER_OPTIONS,
|
|
2903
|
+
...preset,
|
|
2904
|
+
...filteredOptions
|
|
2905
|
+
};
|
|
2906
|
+
return merged;
|
|
2907
|
+
}
|
|
2908
|
+
__name(mergeWithDefaults, "mergeWithDefaults");
|
|
2909
|
+
function createDefaultLoggerProvider(options) {
|
|
2910
|
+
return {
|
|
2911
|
+
provide: Logger11,
|
|
2912
|
+
useFactory: /* @__PURE__ */ __name(() => {
|
|
2913
|
+
const logger = new Logger11();
|
|
2914
|
+
if (options.level && typeof logger.setLogLevels === "function") {
|
|
2915
|
+
const levels = getLevelsUpTo(options.level);
|
|
2916
|
+
logger.setLogLevels(levels);
|
|
2917
|
+
}
|
|
2918
|
+
return logger;
|
|
2919
|
+
}, "useFactory")
|
|
2920
|
+
};
|
|
2921
|
+
}
|
|
2922
|
+
__name(createDefaultLoggerProvider, "createDefaultLoggerProvider");
|
|
2923
|
+
function createLoggerProviders(options = {}) {
|
|
2924
|
+
const mergedOptions = mergeWithDefaults(options);
|
|
2925
|
+
const providers = [
|
|
2926
|
+
// Options provider
|
|
2927
|
+
{
|
|
2928
|
+
provide: LOGGER_MODULE_OPTIONS,
|
|
2929
|
+
useValue: mergedOptions
|
|
2930
|
+
}
|
|
2931
|
+
];
|
|
2932
|
+
if (mergedOptions.provider === "default") {
|
|
2933
|
+
providers.push(createDefaultLoggerProvider(mergedOptions));
|
|
2934
|
+
}
|
|
2935
|
+
providers.push({
|
|
2936
|
+
provide: LoggerService2,
|
|
2937
|
+
useFactory: /* @__PURE__ */ __name((opts, defaultLogger) => {
|
|
2938
|
+
return new LoggerService2(opts, defaultLogger);
|
|
2939
|
+
}, "useFactory"),
|
|
2940
|
+
inject: [
|
|
2941
|
+
LOGGER_MODULE_OPTIONS,
|
|
2942
|
+
{
|
|
2943
|
+
token: Logger11,
|
|
2944
|
+
optional: true
|
|
2945
|
+
}
|
|
2946
|
+
]
|
|
2947
|
+
});
|
|
2948
|
+
providers.push({
|
|
2949
|
+
provide: CorrelationIdMiddleware,
|
|
2950
|
+
useFactory: /* @__PURE__ */ __name(() => {
|
|
2951
|
+
return new CorrelationIdMiddleware({
|
|
2952
|
+
includeInResponse: true,
|
|
2953
|
+
responseHeader: "x-correlation-id"
|
|
2954
|
+
});
|
|
2955
|
+
}, "useFactory")
|
|
2956
|
+
});
|
|
2957
|
+
providers.push({
|
|
2958
|
+
provide: HttpLoggerInterceptor,
|
|
2959
|
+
useFactory: /* @__PURE__ */ __name((logger, opts) => {
|
|
2960
|
+
const httpLoggerOptions = opts.httpLogger ?? {
|
|
2961
|
+
enableRequestLog: opts.enableHttpLogger,
|
|
2962
|
+
enableResponseLog: opts.enableHttpLogger
|
|
2963
|
+
};
|
|
2964
|
+
return new HttpLoggerInterceptor(logger, httpLoggerOptions);
|
|
2965
|
+
}, "useFactory"),
|
|
2966
|
+
inject: [
|
|
2967
|
+
LoggerService2,
|
|
2968
|
+
LOGGER_MODULE_OPTIONS
|
|
2969
|
+
]
|
|
2970
|
+
});
|
|
2971
|
+
return providers;
|
|
2972
|
+
}
|
|
2973
|
+
__name(createLoggerProviders, "createLoggerProviders");
|
|
2974
|
+
function getLevelsUpTo(level) {
|
|
2975
|
+
const allLevels = [
|
|
2976
|
+
"error",
|
|
2977
|
+
"warn",
|
|
2978
|
+
"log",
|
|
2979
|
+
"debug",
|
|
2980
|
+
"verbose"
|
|
2981
|
+
];
|
|
2982
|
+
const levelIndex = allLevels.indexOf(level);
|
|
2983
|
+
if (levelIndex === -1) {
|
|
2984
|
+
return [
|
|
2985
|
+
"error",
|
|
2986
|
+
"warn",
|
|
2987
|
+
"log"
|
|
2988
|
+
];
|
|
2989
|
+
}
|
|
2990
|
+
return allLevels.slice(0, levelIndex + 1);
|
|
2991
|
+
}
|
|
2992
|
+
__name(getLevelsUpTo, "getLevelsUpTo");
|
|
2993
|
+
var LoggerModule = class _LoggerModule {
|
|
2994
|
+
static {
|
|
2995
|
+
__name(this, "LoggerModule");
|
|
2996
|
+
}
|
|
2997
|
+
/**
|
|
2998
|
+
* Configures the logger module with static options.
|
|
2999
|
+
*
|
|
3000
|
+
* Users must explicitly pass `environment` to select a preset.
|
|
3001
|
+
* All preset values can be overridden by passing explicit options.
|
|
3002
|
+
*
|
|
3003
|
+
* @param options - Logger configuration options
|
|
3004
|
+
* @returns Dynamic module configuration
|
|
3005
|
+
*
|
|
3006
|
+
* @example
|
|
3007
|
+
* ```typescript
|
|
3008
|
+
* // Production preset with app name
|
|
3009
|
+
* LoggerModule.forRoot({
|
|
3010
|
+
* environment: 'production',
|
|
3011
|
+
* appName: 'my-service'
|
|
3012
|
+
* })
|
|
3013
|
+
*
|
|
3014
|
+
* // Development preset with custom level
|
|
3015
|
+
* LoggerModule.forRoot({
|
|
3016
|
+
* environment: 'development',
|
|
3017
|
+
* level: 'verbose',
|
|
3018
|
+
* enableFileLogger: true
|
|
3019
|
+
* })
|
|
3020
|
+
*
|
|
3021
|
+
* // Use default NestJS logger
|
|
3022
|
+
* LoggerModule.forRoot({
|
|
3023
|
+
* provider: 'default',
|
|
3024
|
+
* environment: 'development'
|
|
3025
|
+
* })
|
|
3026
|
+
* ```
|
|
3027
|
+
*/
|
|
3028
|
+
static forRoot(options = {}) {
|
|
3029
|
+
const providers = createLoggerProviders(options);
|
|
3030
|
+
return {
|
|
3031
|
+
module: _LoggerModule,
|
|
3032
|
+
providers,
|
|
3033
|
+
exports: [
|
|
3034
|
+
LoggerService2,
|
|
3035
|
+
CorrelationIdMiddleware,
|
|
3036
|
+
HttpLoggerInterceptor,
|
|
3037
|
+
LOGGER_MODULE_OPTIONS
|
|
3038
|
+
]
|
|
3039
|
+
};
|
|
3040
|
+
}
|
|
3041
|
+
/**
|
|
3042
|
+
* Configures the logger module with async options.
|
|
3043
|
+
*
|
|
3044
|
+
* Supports dynamic configuration using:
|
|
3045
|
+
* - `useFactory`: Factory function with dependency injection
|
|
3046
|
+
* - `useClass`: Class implementing `LoggerOptionsFactory`
|
|
3047
|
+
* - `useExisting`: Existing provider implementing `LoggerOptionsFactory`
|
|
3048
|
+
*
|
|
3049
|
+
* Options from the factory/class are merged with environment preset defaults.
|
|
3050
|
+
*
|
|
3051
|
+
* @param options - Async configuration options
|
|
3052
|
+
* @returns Dynamic module configuration
|
|
3053
|
+
*
|
|
3054
|
+
* @example
|
|
3055
|
+
* ```typescript
|
|
3056
|
+
* // Factory with ConfigService
|
|
3057
|
+
* LoggerModule.forRootAsync({
|
|
3058
|
+
* imports: [ConfigModule],
|
|
3059
|
+
* useFactory: (config: ConfigService) => ({
|
|
3060
|
+
* environment: config.get('NODE_ENV', 'development'),
|
|
3061
|
+
* provider: config.get('LOG_PROVIDER', 'winston'),
|
|
3062
|
+
* level: config.get('LOG_LEVEL'),
|
|
3063
|
+
* appName: config.get('APP_NAME'),
|
|
3064
|
+
* }),
|
|
3065
|
+
* inject: [ConfigService]
|
|
3066
|
+
* })
|
|
3067
|
+
*
|
|
3068
|
+
* // Factory class
|
|
3069
|
+
* @Injectable()
|
|
3070
|
+
* class LoggerConfigService implements LoggerOptionsFactory {
|
|
3071
|
+
* createLoggerOptions(): LoggerModuleOptions {
|
|
3072
|
+
* return {
|
|
3073
|
+
* environment: 'production',
|
|
3074
|
+
* appName: 'my-service'
|
|
3075
|
+
* };
|
|
3076
|
+
* }
|
|
3077
|
+
* }
|
|
3078
|
+
*
|
|
3079
|
+
* LoggerModule.forRootAsync({
|
|
3080
|
+
* useClass: LoggerConfigService
|
|
3081
|
+
* })
|
|
3082
|
+
* ```
|
|
3083
|
+
*/
|
|
3084
|
+
static forRootAsync(options) {
|
|
3085
|
+
const asyncProviders = this.createAsyncProviders(options);
|
|
3086
|
+
return {
|
|
3087
|
+
module: _LoggerModule,
|
|
3088
|
+
imports: options.imports || [],
|
|
3089
|
+
providers: [
|
|
3090
|
+
...asyncProviders,
|
|
3091
|
+
// Default logger provider
|
|
3092
|
+
{
|
|
3093
|
+
provide: Logger11,
|
|
3094
|
+
useFactory: /* @__PURE__ */ __name((opts) => {
|
|
3095
|
+
if (opts.provider === "default") {
|
|
3096
|
+
const logger = new Logger11();
|
|
3097
|
+
if (opts.level && typeof logger.setLogLevels === "function") {
|
|
3098
|
+
const levels = getLevelsUpTo(opts.level);
|
|
3099
|
+
logger.setLogLevels(levels);
|
|
3100
|
+
}
|
|
3101
|
+
return logger;
|
|
3102
|
+
}
|
|
3103
|
+
return null;
|
|
3104
|
+
}, "useFactory"),
|
|
3105
|
+
inject: [
|
|
3106
|
+
LOGGER_MODULE_OPTIONS
|
|
3107
|
+
]
|
|
3108
|
+
},
|
|
3109
|
+
// Unified logger service
|
|
3110
|
+
{
|
|
3111
|
+
provide: LoggerService2,
|
|
3112
|
+
useFactory: /* @__PURE__ */ __name((opts, defaultLogger) => {
|
|
3113
|
+
return new LoggerService2(opts, defaultLogger);
|
|
3114
|
+
}, "useFactory"),
|
|
3115
|
+
inject: [
|
|
3116
|
+
LOGGER_MODULE_OPTIONS,
|
|
3117
|
+
{
|
|
3118
|
+
token: Logger11,
|
|
3119
|
+
optional: true
|
|
3120
|
+
}
|
|
3121
|
+
]
|
|
3122
|
+
},
|
|
3123
|
+
// Correlation ID middleware
|
|
3124
|
+
{
|
|
3125
|
+
provide: CorrelationIdMiddleware,
|
|
3126
|
+
useFactory: /* @__PURE__ */ __name(() => {
|
|
3127
|
+
return new CorrelationIdMiddleware({
|
|
3128
|
+
includeInResponse: true,
|
|
3129
|
+
responseHeader: "x-correlation-id"
|
|
3130
|
+
});
|
|
3131
|
+
}, "useFactory")
|
|
3132
|
+
},
|
|
3133
|
+
// HTTP logger interceptor
|
|
3134
|
+
{
|
|
3135
|
+
provide: HttpLoggerInterceptor,
|
|
3136
|
+
useFactory: /* @__PURE__ */ __name((logger, opts) => {
|
|
3137
|
+
const httpLoggerOptions = opts.httpLogger ?? {
|
|
3138
|
+
enableRequestLog: opts.enableHttpLogger,
|
|
3139
|
+
enableResponseLog: opts.enableHttpLogger
|
|
3140
|
+
};
|
|
3141
|
+
return new HttpLoggerInterceptor(logger, httpLoggerOptions);
|
|
3142
|
+
}, "useFactory"),
|
|
3143
|
+
inject: [
|
|
3144
|
+
LoggerService2,
|
|
3145
|
+
LOGGER_MODULE_OPTIONS
|
|
3146
|
+
]
|
|
3147
|
+
}
|
|
3148
|
+
],
|
|
3149
|
+
exports: [
|
|
3150
|
+
LoggerService2,
|
|
3151
|
+
CorrelationIdMiddleware,
|
|
3152
|
+
HttpLoggerInterceptor,
|
|
3153
|
+
LOGGER_MODULE_OPTIONS
|
|
3154
|
+
]
|
|
3155
|
+
};
|
|
3156
|
+
}
|
|
3157
|
+
/**
|
|
3158
|
+
* Configures middleware for the module.
|
|
3159
|
+
* Middleware is registered globally in main.ts using Fastify hooks.
|
|
3160
|
+
*/
|
|
3161
|
+
configure(consumer) {
|
|
3162
|
+
}
|
|
3163
|
+
/**
|
|
3164
|
+
* Creates async providers for dynamic module configuration.
|
|
3165
|
+
*/
|
|
3166
|
+
static createAsyncProviders(options) {
|
|
3167
|
+
if (options.useFactory) {
|
|
3168
|
+
return [
|
|
3169
|
+
this.createAsyncOptionsProvider(options)
|
|
3170
|
+
];
|
|
3171
|
+
}
|
|
3172
|
+
const providers = [
|
|
3173
|
+
this.createAsyncOptionsProvider(options)
|
|
3174
|
+
];
|
|
3175
|
+
if (options.useClass) {
|
|
3176
|
+
providers.push({
|
|
3177
|
+
provide: options.useClass,
|
|
3178
|
+
useClass: options.useClass
|
|
3179
|
+
});
|
|
3180
|
+
}
|
|
3181
|
+
return providers;
|
|
3182
|
+
}
|
|
3183
|
+
/**
|
|
3184
|
+
* Creates the async options provider.
|
|
3185
|
+
*/
|
|
3186
|
+
static createAsyncOptionsProvider(options) {
|
|
3187
|
+
if (options.useFactory) {
|
|
3188
|
+
return {
|
|
3189
|
+
provide: LOGGER_MODULE_OPTIONS,
|
|
3190
|
+
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
3191
|
+
const userOptions = await options.useFactory(...args);
|
|
3192
|
+
return mergeWithDefaults(userOptions);
|
|
3193
|
+
}, "useFactory"),
|
|
3194
|
+
inject: options.inject || []
|
|
3195
|
+
};
|
|
3196
|
+
}
|
|
3197
|
+
if (options.useClass) {
|
|
3198
|
+
return {
|
|
3199
|
+
provide: LOGGER_MODULE_OPTIONS,
|
|
3200
|
+
useFactory: /* @__PURE__ */ __name(async (optionsFactory) => {
|
|
3201
|
+
const userOptions = await optionsFactory.createLoggerOptions();
|
|
3202
|
+
return mergeWithDefaults(userOptions);
|
|
3203
|
+
}, "useFactory"),
|
|
3204
|
+
inject: [
|
|
3205
|
+
options.useClass
|
|
3206
|
+
]
|
|
3207
|
+
};
|
|
3208
|
+
}
|
|
3209
|
+
if (options.useExisting) {
|
|
3210
|
+
return {
|
|
3211
|
+
provide: LOGGER_MODULE_OPTIONS,
|
|
3212
|
+
useFactory: /* @__PURE__ */ __name(async (optionsFactory) => {
|
|
3213
|
+
const userOptions = await optionsFactory.createLoggerOptions();
|
|
3214
|
+
return mergeWithDefaults(userOptions);
|
|
3215
|
+
}, "useFactory"),
|
|
3216
|
+
inject: [
|
|
3217
|
+
options.useExisting
|
|
3218
|
+
]
|
|
3219
|
+
};
|
|
3220
|
+
}
|
|
3221
|
+
throw new Error("LoggerModule.forRootAsync() requires one of: useFactory, useClass, or useExisting");
|
|
3222
|
+
}
|
|
3223
|
+
};
|
|
3224
|
+
LoggerModule = _ts_decorate17([
|
|
3225
|
+
Global4(),
|
|
3226
|
+
Module5({})
|
|
3227
|
+
], LoggerModule);
|
|
2348
3228
|
export {
|
|
2349
3229
|
AuthConfigModule,
|
|
2350
3230
|
BadGatewayException,
|
|
2351
3231
|
BadRequestException,
|
|
2352
3232
|
BaseFieldException,
|
|
2353
3233
|
ConflictException,
|
|
3234
|
+
CorrelationIdMiddleware,
|
|
2354
3235
|
CsrfGuard,
|
|
3236
|
+
DEFAULT_CORRELATION_HEADER,
|
|
2355
3237
|
DatabaseModule,
|
|
2356
3238
|
ForbiddenException2 as ForbiddenException,
|
|
2357
3239
|
GoneException,
|
|
2358
3240
|
HttpExceptionFilter,
|
|
3241
|
+
HttpLoggerInterceptor,
|
|
2359
3242
|
HttpModule,
|
|
2360
3243
|
InternalServerErrorException3 as InternalServerErrorException,
|
|
3244
|
+
LOGGER_MODULE_OPTIONS,
|
|
3245
|
+
LoggerModule,
|
|
3246
|
+
LoggerService2 as LoggerService,
|
|
2361
3247
|
MethodNotAllowedException,
|
|
2362
3248
|
NotAcceptableException,
|
|
2363
3249
|
NotFoundException,
|
|
@@ -2379,6 +3265,12 @@ export {
|
|
|
2379
3265
|
UnsupportedMediaTypeException,
|
|
2380
3266
|
ValidationException,
|
|
2381
3267
|
VrittiAuthGuard,
|
|
2382
|
-
|
|
3268
|
+
addCorrelationIdToResponse,
|
|
3269
|
+
correlationStorage,
|
|
3270
|
+
generateCorrelationId,
|
|
3271
|
+
getCorrelationContext,
|
|
3272
|
+
getHttpStatusTitle,
|
|
3273
|
+
runWithCorrelationContext,
|
|
3274
|
+
updateCorrelationContext
|
|
2383
3275
|
};
|
|
2384
3276
|
//# sourceMappingURL=index.js.map
|