@gennext/lb-infra 0.0.8 → 0.0.10

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.
Files changed (57) hide show
  1. package/README.md +146 -0
  2. package/dist/helpers/logger/common/types.d.ts +15 -0
  3. package/dist/helpers/logger/common/types.d.ts.map +1 -1
  4. package/dist/helpers/logger/common/types.js +19 -1
  5. package/dist/helpers/logger/common/types.js.map +1 -1
  6. package/dist/helpers/logger/config.d.ts +34 -0
  7. package/dist/helpers/logger/config.d.ts.map +1 -0
  8. package/dist/helpers/logger/config.js +71 -0
  9. package/dist/helpers/logger/config.js.map +1 -0
  10. package/dist/helpers/logger/enhanced-factory.d.ts +1 -1
  11. package/dist/helpers/logger/factory.d.ts +41 -1
  12. package/dist/helpers/logger/factory.d.ts.map +1 -1
  13. package/dist/helpers/logger/factory.js +98 -5
  14. package/dist/helpers/logger/factory.js.map +1 -1
  15. package/dist/helpers/logger/http/access-logger.d.ts +25 -4
  16. package/dist/helpers/logger/http/access-logger.d.ts.map +1 -1
  17. package/dist/helpers/logger/http/access-logger.js +159 -22
  18. package/dist/helpers/logger/http/access-logger.js.map +1 -1
  19. package/dist/helpers/logger/http/client-ip.d.ts +1 -1
  20. package/dist/helpers/logger/http/client-ip.d.ts.map +1 -1
  21. package/dist/helpers/logger/http/client-ip.js +4 -15
  22. package/dist/helpers/logger/http/client-ip.js.map +1 -1
  23. package/dist/helpers/logger/http/index.d.ts +1 -1
  24. package/dist/helpers/logger/http/index.d.ts.map +1 -1
  25. package/dist/helpers/logger/http/index.js +1 -1
  26. package/dist/helpers/logger/http/index.js.map +1 -1
  27. package/dist/helpers/logger/http/request-context.d.ts.map +1 -1
  28. package/dist/helpers/logger/http/request-context.js +2 -6
  29. package/dist/helpers/logger/http/request-context.js.map +1 -1
  30. package/dist/helpers/logger/http/request-id-manager.d.ts +17 -0
  31. package/dist/helpers/logger/http/request-id-manager.d.ts.map +1 -0
  32. package/dist/helpers/logger/http/request-id-manager.js +98 -0
  33. package/dist/helpers/logger/http/request-id-manager.js.map +1 -0
  34. package/dist/helpers/logger/http/types.d.ts +10 -6
  35. package/dist/helpers/logger/http/types.d.ts.map +1 -1
  36. package/dist/helpers/logger/index.d.ts +1 -0
  37. package/dist/helpers/logger/index.d.ts.map +1 -1
  38. package/dist/helpers/logger/index.js +1 -0
  39. package/dist/helpers/logger/index.js.map +1 -1
  40. package/dist/helpers/logger/transports/dgram.transport.d.ts +2 -2
  41. package/dist/helpers/logger/transports/dgram.transport.d.ts.map +1 -1
  42. package/dist/helpers/logger/transports/dgram.transport.js +6 -11
  43. package/dist/helpers/logger/transports/dgram.transport.js.map +1 -1
  44. package/dist/helpers/logger/transports/index.d.ts +1 -1
  45. package/dist/utilities/lodash.utility.d.ts +3 -0
  46. package/dist/utilities/lodash.utility.d.ts.map +1 -0
  47. package/dist/utilities/lodash.utility.js +11 -0
  48. package/dist/utilities/lodash.utility.js.map +1 -0
  49. package/dist/utilities/request.utility.d.ts +2 -1
  50. package/dist/utilities/request.utility.d.ts.map +1 -1
  51. package/dist/utilities/request.utility.js +15 -5
  52. package/dist/utilities/request.utility.js.map +1 -1
  53. package/package.json +1 -1
  54. package/dist/helpers/logger/http/data-masking.d.ts +0 -13
  55. package/dist/helpers/logger/http/data-masking.d.ts.map +0 -1
  56. package/dist/helpers/logger/http/data-masking.js +0 -77
  57. package/dist/helpers/logger/http/data-masking.js.map +0 -1
package/README.md ADDED
@@ -0,0 +1,146 @@
1
+ # @gennext/lb-infra
2
+
3
+ `@gennext/lb-infra` là bộ khung cơ sở (infrastructure framework) được phát triển bởi Gennex Technology dựa trên LoopBack 4. Thư viện này cung cấp các công cụ, tiện ích và các lớp cơ sở giúp tăng tốc độ phát triển các ứng dụng backend một cách nhất quán và bảo mật.
4
+
5
+ ## Tính năng chính
6
+
7
+ - ✅ **Enhanced Logger**: Hệ thống logging mạnh mẽ hỗ trợ ghi log truy cập HTTP, ẩn thông tin nhạy cảm (data masking), theo dõi Request ID và đo lường hiệu suất.
8
+ - ✅ **Base Models & Datasources**: Cung cấp các lớp cơ sở như `BaseEntity`, `BaseDataSource` giúp chuẩn hóa cấu trúc dữ liệu và kết nối DB.
9
+ - ✅ **Datasources**: Hỗ trợ sẵn các cấu hình và lớp kết nối cho PostgreSQL và Redis.
10
+ - ✅ **Redis Helpers**: Tiện ích giúp tương tác với Redis một cách dễ dàng và hiệu quả.
11
+ - ✅ **Common Utilities**: Tập hợp các hàm tiện ích cho Crypto, Date, Error, Promises, Query Builder, URL, v.v.
12
+ - ✅ **LoopBack 4 Overrides**: Re-export và tùy chỉnh các module cốt lõi của LoopBack 4 (@lb/auth, @lb/core, @lb/rest, @lb/repo).
13
+
14
+ ---
15
+
16
+ ## Cài đặt
17
+
18
+ Sử dụng `bun` hoặc `npm`/`yarn`:
19
+
20
+ ```bash
21
+ bun add @gennext/lb-infra
22
+ ```
23
+
24
+ ---
25
+
26
+ ## Hướng dẫn sử dụng
27
+
28
+ ### 1. Cấu hình Logger
29
+
30
+ Hệ thống logger hỗ trợ hai chế độ: `legacy` (tương thích ngược) và `modern`. Bạn nên cấu hình logger ngay khi khởi tạo ứng dụng.
31
+
32
+ ```typescript
33
+ import { LoggerFactory } from '@gennext/lb-infra';
34
+
35
+ // Cấu hình toàn cục (thực hiện một lần tại entry point)
36
+ LoggerFactory.config({
37
+ mode: 'modern',
38
+ defaultDataMasking: {
39
+ useMaskdataLib: true,
40
+ maskdataOptions: {
41
+ genericStrings: [
42
+ {
43
+ config: { maskWith: '*', fixedOutputLength: 8 },
44
+ fields: ['*password', '*secret', '*token'],
45
+ },
46
+ ],
47
+ },
48
+ },
49
+ defaultRequestIDSystem: 'asyncLocalStorage',
50
+ defaultLogFormat: 'modern',
51
+ });
52
+
53
+ const logger = LoggerFactory.getLogger(['UserModule']);
54
+ logger.info('Ứng dụng đã khởi chạy thành công');
55
+ ```
56
+
57
+ ### 2. Sử dụng Base Model
58
+
59
+ Kế thừa các lớp cơ sở để chuẩn hóa các Entity trong LoopBack 4.
60
+
61
+ ```typescript
62
+ import { BaseNumberIdEntity } from '@gennext/lb-infra';
63
+ import { property } from '@loopback/repository';
64
+
65
+ export class User extends BaseNumberIdEntity {
66
+ @property({ type: 'string', required: true })
67
+ username: string;
68
+
69
+ @property({ type: 'string' })
70
+ email?: string;
71
+ }
72
+ ```
73
+
74
+ ### 3. Kết nối PostgreSQL
75
+
76
+ `PostgresDataSource` tự động đọc cấu hình từ biến môi trường.
77
+
78
+ ```typescript
79
+ import { PostgresDataSource } from '@gennext/lb-infra';
80
+
81
+ // Tự động kết nối dựa trên APP_ENV_POSTGRES_* env
82
+ const dataSource = new PostgresDataSource();
83
+ ```
84
+
85
+ ### 4. Sử dụng Redis Helper
86
+
87
+ ```typescript
88
+ import { RedisHelper } from '@gennext/lb-infra';
89
+
90
+ const redis = new RedisHelper({
91
+ name: 'my-redis',
92
+ host: 'localhost',
93
+ port: 6379,
94
+ password: 'your-password'
95
+ });
96
+
97
+ await redis.set('key', 'value');
98
+ const val = await redis.get('key');
99
+ ```
100
+
101
+ ### 5. Sử dụng Common Utilities
102
+
103
+ ```typescript
104
+ import { cryptoUtility, dateUtility, queryUtility } from '@gennext/lb-infra';
105
+
106
+ // Crypto
107
+ const hash = cryptoUtility.md5('password');
108
+
109
+ // Date
110
+ const now = dateUtility.now();
111
+
112
+ // Query Utility
113
+ const tableDef = queryUtility.getTableDefinition({ model: User });
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Cấu hình Biến môi trường (Environment Variables)
119
+
120
+ Thư viện hỗ trợ các biến môi trường sau để cấu hình Datasource:
121
+
122
+ ### PostgreSQL
123
+ - `APP_ENV_POSTGRES_HOST`: Host của DB (mặc định: `0.0.0.0`)
124
+ - `APP_ENV_POSTGRES_PORT`: Port (mặc định: `5432`)
125
+ - `APP_ENV_POSTGRES_USERNAME`: Username (mặc định: `postgres`)
126
+ - `APP_ENV_POSTGRES_PASSWORD`: Password (mặc định: `password`)
127
+ - `APP_ENV_POSTGRES_DATABASE`: Database name (mặc định: `postgres`)
128
+
129
+ ### Logger
130
+ - `APP_ENV_ENABLE_ACCESS_LOG`: Bật/tắt log truy cập (true/false)
131
+ - `APP_ENV_LOG_FORMAT`: Định dạng log (`legacy` hoặc `modern`)
132
+
133
+ ---
134
+
135
+ ## Tài liệu chi tiết
136
+
137
+ Xem thêm các hướng dẫn chi tiết tại thư mục `docs/`:
138
+
139
+ - [Cấu hình hệ thống Logger](./docs/CONFIG_USAGE.md)
140
+ - [Hướng dẫn Logger nâng cao](./docs/ENHANCED_LOGGER_USAGE.md)
141
+ - [Chi tiết về infra](./docs/lb-infra.md)
142
+
143
+ ---
144
+
145
+ ## Liên hệ
146
+ **Gennex Technology Team**
@@ -13,4 +13,19 @@ export declare class LogLevels {
13
13
  static isValid(input: string): boolean;
14
14
  }
15
15
  export type TLogLevel = TConstValue<typeof LogLevels>;
16
+ export type TLogFormat = 'legacy' | 'modern';
17
+ export type TLogMode = 'legacy' | 'modern';
18
+ export type TRequestIDSystem = 'asyncLocalStorage' | 'requestContext';
19
+ export declare class LogModes {
20
+ static readonly LEGACY = "legacy";
21
+ static readonly MODERN = "modern";
22
+ static readonly MODE_SET: Set<string>;
23
+ static isValid(input: string): boolean;
24
+ }
25
+ export declare class RequestIDSystems {
26
+ static readonly ASYNC_LOCAL_STORAGE = "asyncLocalStorage";
27
+ static readonly REQUEST_CONTEXT = "requestContext";
28
+ static readonly SYSTEM_SET: Set<string>;
29
+ static isValid(input: string): boolean;
30
+ }
16
31
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/helpers/logger/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAAa,SAAS;IACpB,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW;IAChC,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW;IAChC,MAAM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Q,GAAG,QAAQ,CAAC;AAC7C,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC3C,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,GAAG,gBAAgB,CAAC;AACtE,qBAAa,QAAQ;IACnB,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAElC,MAAM,CAAC,QAAQ,CAAC,QAAQ,cAAuC;IAE/D,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,QAAQ,CAAC,mBAAmB,uBAAuB;IAC1D,MAAM,CAAC,QAAQ,CAAC,eAAe,oBAAoB;IAEnD,MAAM,CAAC,QAAQ,CAAC,UAAU,cAA6D;IAEvF,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LogLevels = void 0;
3
+ exports.RequestIDSystems = exports.LogModes = exports.LogLevels = void 0;
4
4
  class LogLevels {
5
5
  static { this.ERROR = 'error'; }
6
6
  static { this.ALERT = 'alert'; }
@@ -27,4 +27,22 @@ class LogLevels {
27
27
  }
28
28
  }
29
29
  exports.LogLevels = LogLevels;
30
+ class LogModes {
31
+ static { this.LEGACY = 'legacy'; }
32
+ static { this.MODERN = 'modern'; }
33
+ static { this.MODE_SET = new Set([this.LEGACY, this.MODERN]); }
34
+ static isValid(input) {
35
+ return this.MODE_SET.has(input);
36
+ }
37
+ }
38
+ exports.LogModes = LogModes;
39
+ class RequestIDSystems {
40
+ static { this.ASYNC_LOCAL_STORAGE = 'asyncLocalStorage'; }
41
+ static { this.REQUEST_CONTEXT = 'requestContext'; }
42
+ static { this.SYSTEM_SET = new Set([this.ASYNC_LOCAL_STORAGE, this.REQUEST_CONTEXT]); }
43
+ static isValid(input) {
44
+ return this.SYSTEM_SET.has(input);
45
+ }
46
+ }
47
+ exports.RequestIDSystems = RequestIDSystems;
30
48
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/helpers/logger/common/types.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAS;aACJ,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;aACd,YAAO,GAAG,SAAS,CAAC;aACpB,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAEhB,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;KACX,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAzBH,8BA0BC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/helpers/logger/common/types.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAS;aACJ,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;aACd,YAAO,GAAG,SAAS,CAAC;aACpB,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAEhB,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;KACX,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAzBH,8BA0BC;AAMD,MAAa,QAAQ;aACH,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAElB,aAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE/D,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;;AARH,4BASC;AAED,MAAa,gBAAgB;aACX,wBAAmB,GAAG,mBAAmB,CAAC;aAC1C,oBAAe,GAAG,gBAAgB,CAAC;aAEnC,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IAEvF,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AARH,4CASC"}
@@ -0,0 +1,34 @@
1
+ import { TLogFormat, TLogMode, TRequestIDSystem } from './common/types';
2
+ export interface ILoggerFactoryConfig {
3
+ mode?: TLogMode;
4
+ defaultDataMasking?: {
5
+ useMaskdataLib: boolean;
6
+ maskdataOptions?: any;
7
+ };
8
+ defaultRequestIDSystem?: TRequestIDSystem;
9
+ defaultLogFormat?: TLogFormat;
10
+ enableAccessLog?: boolean;
11
+ }
12
+ export declare const DEFAULT_MASKDATA_OPTIONS: {
13
+ genericStrings: {
14
+ config: {
15
+ maskWith: string;
16
+ fixedOutputLength: number;
17
+ };
18
+ fields: string[];
19
+ }[];
20
+ };
21
+ export declare const maskSensitiveData: (data: any, options?: any) => any;
22
+ export declare class LoggerFactoryConfigManager {
23
+ private static config;
24
+ static setConfig(config: Partial<ILoggerFactoryConfig>): void;
25
+ static getConfig(): ILoggerFactoryConfig;
26
+ static getMode(): TLogMode;
27
+ static isLegacyMode(): boolean;
28
+ static isModernMode(): boolean;
29
+ static getDefaultDataMaskingOptions(): any;
30
+ static getDefaultRequestIDSystem(): TRequestIDSystem;
31
+ static getDefaultLogFormat(): TLogFormat;
32
+ static isAccessLogEnabled(): boolean;
33
+ }
34
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/helpers/logger/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8B,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEpG,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,kBAAkB,CAAC,EAAE;QACnB,cAAc,EAAE,OAAO,CAAC;QACxB,eAAe,CAAC,EAAE,GAAG,CAAC;KACvB,CAAC;IACF,sBAAsB,CAAC,EAAE,gBAAgB,CAAC;IAC1C,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAC9B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,wBAAwB;;;;;;;;CAUpC,CAAC;AAGF,eAAO,MAAM,iBAAiB,GAAI,MAAM,GAAG,EAAE,UAAU,GAAG,KAAG,GAG5D,CAAC;AAGF,qBAAa,0BAA0B;IACrC,OAAO,CAAC,MAAM,CAAC,MAAM,CASnB;IAEF,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,IAAI;IAY7D,MAAM,CAAC,SAAS,IAAI,oBAAoB;IAIxC,MAAM,CAAC,OAAO,IAAI,QAAQ;IAI1B,MAAM,CAAC,YAAY,IAAI,OAAO;IAI9B,MAAM,CAAC,YAAY,IAAI,OAAO;IAI9B,MAAM,CAAC,4BAA4B,IAAI,GAAG;IAI1C,MAAM,CAAC,yBAAyB,IAAI,gBAAgB;IAIpD,MAAM,CAAC,mBAAmB,IAAI,UAAU;IAIxC,MAAM,CAAC,kBAAkB,IAAI,OAAO;CAGrC"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoggerFactoryConfigManager = exports.maskSensitiveData = exports.DEFAULT_MASKDATA_OPTIONS = void 0;
4
+ const maskdata_1 = require("maskdata");
5
+ const types_1 = require("./common/types");
6
+ exports.DEFAULT_MASKDATA_OPTIONS = {
7
+ genericStrings: [
8
+ {
9
+ config: {
10
+ maskWith: '*',
11
+ fixedOutputLength: 8,
12
+ },
13
+ fields: ['*password'],
14
+ },
15
+ ],
16
+ };
17
+ // Simplified data masking wrapper using maskdata library
18
+ const maskSensitiveData = (data, options) => {
19
+ const maskingOptions = options || exports.DEFAULT_MASKDATA_OPTIONS;
20
+ return (0, maskdata_1.maskJSON2)(data, maskingOptions);
21
+ };
22
+ exports.maskSensitiveData = maskSensitiveData;
23
+ // Global configuration class
24
+ class LoggerFactoryConfigManager {
25
+ static { this.config = {
26
+ mode: types_1.LogModes.LEGACY,
27
+ defaultDataMasking: {
28
+ useMaskdataLib: true,
29
+ maskdataOptions: exports.DEFAULT_MASKDATA_OPTIONS,
30
+ },
31
+ defaultRequestIDSystem: types_1.RequestIDSystems.ASYNC_LOCAL_STORAGE,
32
+ defaultLogFormat: types_1.LogModes.LEGACY,
33
+ enableAccessLog: true,
34
+ }; }
35
+ static setConfig(config) {
36
+ this.config = { ...this.config, ...config };
37
+ // Update default data masking if provided
38
+ if (config.defaultDataMasking) {
39
+ this.config.defaultDataMasking = {
40
+ maskdataOptions: exports.DEFAULT_MASKDATA_OPTIONS,
41
+ ...config.defaultDataMasking,
42
+ };
43
+ }
44
+ }
45
+ static getConfig() {
46
+ return { ...this.config };
47
+ }
48
+ static getMode() {
49
+ return this.config.mode || types_1.LogModes.LEGACY;
50
+ }
51
+ static isLegacyMode() {
52
+ return this.getMode() === types_1.LogModes.LEGACY;
53
+ }
54
+ static isModernMode() {
55
+ return this.getMode() === types_1.LogModes.MODERN;
56
+ }
57
+ static getDefaultDataMaskingOptions() {
58
+ return this.config.defaultDataMasking?.maskdataOptions || exports.DEFAULT_MASKDATA_OPTIONS;
59
+ }
60
+ static getDefaultRequestIDSystem() {
61
+ return this.config.defaultRequestIDSystem || types_1.RequestIDSystems.ASYNC_LOCAL_STORAGE;
62
+ }
63
+ static getDefaultLogFormat() {
64
+ return this.config.defaultLogFormat || types_1.LogModes.LEGACY;
65
+ }
66
+ static isAccessLogEnabled() {
67
+ return this.config.enableAccessLog ?? (this.isLegacyMode() ? true : false);
68
+ }
69
+ }
70
+ exports.LoggerFactoryConfigManager = LoggerFactoryConfigManager;
71
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/helpers/logger/config.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AAErC,0CAAoG;AAavF,QAAA,wBAAwB,GAAG;IACtC,cAAc,EAAE;QACd;YACE,MAAM,EAAE;gBACN,QAAQ,EAAE,GAAG;gBACb,iBAAiB,EAAE,CAAC;aACrB;YACD,MAAM,EAAE,CAAC,WAAW,CAAC;SACtB;KACF;CACF,CAAC;AAEF,yDAAyD;AAClD,MAAM,iBAAiB,GAAG,CAAC,IAAS,EAAE,OAAa,EAAO,EAAE;IACjE,MAAM,cAAc,GAAG,OAAO,IAAI,gCAAwB,CAAC;IAC3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AwB,CAAC;IACrF,CAAC;IAED,MAAM,CAAC,yBAAyB;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,IAAI,wBAAgB,CAAC,mBAAmB,CAAC;IACpF,CAAC;IAED,MAAM,CAAC,mBAAmB;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,gBAAgB,IAAI,gBAAQ,CAAC,MAAM,CAAC;IACzD,CAAC;IAED,MAAM,CAAC,kBAAkB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC7E,CAAC;;AAtDH,gEAuDC"}
@@ -9,6 +9,6 @@ export declare class EnhancedLoggerFactory {
9
9
  private static httpLoggers;
10
10
  static createEnhancedLogger(scopes: string[], httpOptions?: IEnhancedLoggerOptions, customLogger?: Logger): IEnhancedLogger;
11
11
  static getHttpLogger(scopes: string[]): HttpAccessLogger | null;
12
- static createHttpMiddleware(scopes: string[], _options?: IEnhancedLoggerOptions): (req: any, res: any, next: () => void) => void;
12
+ static createHttpMiddleware(scopes: string[], _options?: IEnhancedLoggerOptions): (req: import("../..").AnyType, res: import("../..").AnyType, next: () => void) => void;
13
13
  }
14
14
  //# sourceMappingURL=enhanced-factory.d.ts.map
@@ -1,9 +1,49 @@
1
1
  import { Logger } from './application-logger';
2
2
  import { IEnhancedLogger } from './enhanced-factory';
3
3
  import { IEnhancedLoggerOptions } from './http/types';
4
+ import { ILoggerFactoryConfig } from './config';
4
5
  export declare class LoggerFactory {
6
+ /**
7
+ * Configure global logger settings
8
+ */
9
+ static config(config: Partial<ILoggerFactoryConfig>): void;
10
+ /**
11
+ * Get current configuration
12
+ */
13
+ static getConfig(): ILoggerFactoryConfig;
14
+ /**
15
+ * Get logger based on global configuration
16
+ * - Legacy mode: returns ApplicationLogger for backward compatibility
17
+ * - Modern mode: returns EnhancedLogger with default options
18
+ */
5
19
  static getLogger(scopes: string[], customLogger?: Logger): Logger;
20
+ /**
21
+ * Get enhanced logger with explicit options
22
+ */
6
23
  static getEnhancedLogger(scopes: string[], httpOptions?: IEnhancedLoggerOptions, customLogger?: Logger): IEnhancedLogger;
7
- static createHttpMiddleware(scopes: string[], options?: IEnhancedLoggerOptions): (req: any, res: any, next: () => void) => void;
24
+ /**
25
+ * Create HTTP middleware based on global configuration
26
+ */
27
+ static createHttpMiddleware(scopes: string[], options?: IEnhancedLoggerOptions): (req: import("../..").AnyType, res: import("../..").AnyType, next: () => void) => void;
28
+ /**
29
+ * Get default options based on global configuration
30
+ */
31
+ private static getDefaultOptions;
32
+ /**
33
+ * Merge provided options with global defaults
34
+ */
35
+ private static mergeWithDefaults;
36
+ /**
37
+ * Utility method to mask sensitive data using global config
38
+ */
39
+ static maskData(data: any, customOptions?: any): any;
40
+ /**
41
+ * Check if running in legacy mode
42
+ */
43
+ static isLegacyMode(): boolean;
44
+ /**
45
+ * Check if running in modern mode
46
+ */
47
+ static isModernMode(): boolean;
8
48
  }
9
49
  //# sourceMappingURL=factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/helpers/logger/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAyB,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,qBAAa,aAAa;IACxB,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM;IAMjE,MAAM,CAAC,iBAAiB,CACtB,MAAM,EAAE,MAAM,EAAE,EAChB,WAAW,CAAC,EAAE,sBAAsB,EACpC,YAAY,CAAC,EAAE,MAAM,GACpB,eAAe;IAIlB,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,sBAAsB;CAG/E"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/helpers/logger/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAyB,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAA8B,oBAAoB,EAAqB,MAAM,UAAU,CAAC;AAE/F,qBAAa,aAAa;IACxB;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,IAAI;IAI1D;;OAEG;IACH,MAAM,CAAC,SAAS,IAAI,oBAAoB;IAIxC;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM;IAejE;;OAEG;IACH,MAAM,CAAC,iBAAiB,CACtB,MAAM,EAAE,MAAM,EAAE,EAChB,WAAW,CAAC,EAAE,sBAAsB,EACpC,YAAY,CAAC,EAAE,MAAM,GACpB,eAAe;IAMlB;;OAEG;IACH,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,sBAAsB;IAK9E;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAiBhC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAsBhC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,aAAa,CAAC,EAAE,GAAG,GAAG,GAAG;IAMpD;;OAEG;IACH,MAAM,CAAC,YAAY,IAAI,OAAO;IAI9B;;OAEG;IACH,MAAM,CAAC,YAAY,IAAI,OAAO;CAG/B"}
@@ -3,17 +3,110 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LoggerFactory = void 0;
4
4
  const application_logger_1 = require("./application-logger");
5
5
  const enhanced_factory_1 = require("./enhanced-factory");
6
+ const config_1 = require("./config");
6
7
  class LoggerFactory {
8
+ /**
9
+ * Configure global logger settings
10
+ */
11
+ static config(config) {
12
+ config_1.LoggerFactoryConfigManager.setConfig(config);
13
+ }
14
+ /**
15
+ * Get current configuration
16
+ */
17
+ static getConfig() {
18
+ return config_1.LoggerFactoryConfigManager.getConfig();
19
+ }
20
+ /**
21
+ * Get logger based on global configuration
22
+ * - Legacy mode: returns ApplicationLogger for backward compatibility
23
+ * - Modern mode: returns EnhancedLogger with default options
24
+ */
7
25
  static getLogger(scopes, customLogger) {
8
- const logger = customLogger ?? new application_logger_1.ApplicationLogger();
9
- logger.withScope(scopes.join('-'));
10
- return logger;
26
+ const mode = config_1.LoggerFactoryConfigManager.getMode();
27
+ if (mode === 'legacy') {
28
+ // Return legacy ApplicationLogger for backward compatibility
29
+ const logger = customLogger ?? new application_logger_1.ApplicationLogger();
30
+ logger.withScope(scopes.join('-'));
31
+ return logger;
32
+ }
33
+ else {
34
+ // Return enhanced logger in modern mode
35
+ const enhancedLogger = this.getEnhancedLogger(scopes, this.getDefaultOptions(), customLogger);
36
+ return enhancedLogger.application;
37
+ }
11
38
  }
39
+ /**
40
+ * Get enhanced logger with explicit options
41
+ */
12
42
  static getEnhancedLogger(scopes, httpOptions, customLogger) {
13
- return enhanced_factory_1.EnhancedLoggerFactory.createEnhancedLogger(scopes, httpOptions, customLogger);
43
+ // Merge with global defaults
44
+ const mergedOptions = this.mergeWithDefaults(httpOptions);
45
+ return enhanced_factory_1.EnhancedLoggerFactory.createEnhancedLogger(scopes, mergedOptions, customLogger);
14
46
  }
47
+ /**
48
+ * Create HTTP middleware based on global configuration
49
+ */
15
50
  static createHttpMiddleware(scopes, options) {
16
- return enhanced_factory_1.EnhancedLoggerFactory.createHttpMiddleware(scopes, options);
51
+ const mergedOptions = this.mergeWithDefaults(options);
52
+ return enhanced_factory_1.EnhancedLoggerFactory.createHttpMiddleware(scopes, mergedOptions);
53
+ }
54
+ /**
55
+ * Get default options based on global configuration
56
+ */
57
+ static getDefaultOptions() {
58
+ const config = config_1.LoggerFactoryConfigManager.getConfig();
59
+ return {
60
+ enableAccessLog: config.enableAccessLog,
61
+ enablePerformanceMetrics: config.mode === 'modern',
62
+ enableDataMasking: true,
63
+ dataMaskingConfig: {
64
+ useMaskdataLib: true,
65
+ maskdataOptions: config.defaultDataMasking?.maskdataOptions,
66
+ },
67
+ logFormat: config.defaultLogFormat,
68
+ requestIdSystem: config.defaultRequestIDSystem,
69
+ sanitizeRequestData: true,
70
+ };
71
+ }
72
+ /**
73
+ * Merge provided options with global defaults
74
+ */
75
+ static mergeWithDefaults(providedOptions) {
76
+ const defaults = this.getDefaultOptions();
77
+ if (!providedOptions) {
78
+ return defaults;
79
+ }
80
+ // Deep merge for dataMaskingConfig
81
+ const mergedDataMaskingConfig = {
82
+ ...defaults.dataMaskingConfig,
83
+ ...providedOptions.dataMaskingConfig,
84
+ };
85
+ return {
86
+ ...defaults,
87
+ ...providedOptions,
88
+ dataMaskingConfig: mergedDataMaskingConfig,
89
+ };
90
+ }
91
+ /**
92
+ * Utility method to mask sensitive data using global config
93
+ */
94
+ static maskData(data, customOptions) {
95
+ const globalOptions = config_1.LoggerFactoryConfigManager.getDefaultDataMaskingOptions();
96
+ const options = customOptions || globalOptions;
97
+ return (0, config_1.maskSensitiveData)(data, options);
98
+ }
99
+ /**
100
+ * Check if running in legacy mode
101
+ */
102
+ static isLegacyMode() {
103
+ return config_1.LoggerFactoryConfigManager.isLegacyMode();
104
+ }
105
+ /**
106
+ * Check if running in modern mode
107
+ */
108
+ static isModernMode() {
109
+ return config_1.LoggerFactoryConfigManager.isModernMode();
17
110
  }
18
111
  }
19
112
  exports.LoggerFactory = LoggerFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/helpers/logger/factory.ts"],"names":[],"mappings":";;;AAAA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,eAAwC;QAExC,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAE1C,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,mCAAmC;QACnC,MAAM,uBAAuB,GAAG;YAC9B,GAAG,QAAQ,CAAC,iBAAiB;YAC7B,GAAG,eAAe,CAAC,iBAAiB;SACrC,CAAC;QAEF,OAAO;YACL,GAAG,QAAQ;YACX,GAAG,eAAe;YAClB,iBAAiB,EAAE,uBAAuB;SAC3C,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAS,EAAE,aAAmB;QAC5C,MAAM,aAAa,GAAG,mCAA0B,CAAC,4BAA4B,EAAE,CAAC;QAChF,MAAM,OAAO,GAAG,aAAa,IAAI,aAAa,CAAC;QAC/C,OAAO,IAAA,0BAAiB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAAY;QACjB,OAAO,mCAA0B,CAAC,YAAY,EAAE,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAAY;QACjB,OAAO,mCAA0B,CAAC,YAAY,EAAE,CAAC;IACnD,CAAC;CACF;AA3HD,sCA2HC"}
@@ -1,14 +1,35 @@
1
+ import { AnyType } from '../../../common';
2
+ import { TLogLevel } from '../../../helpers/logger/common/types';
1
3
  import { ApplicationLogger } from '../application-logger';
2
- import { IAccessLogEntry, IHttpAccessLogger, IPerformanceMetrics, IEnhancedLoggerOptions } from './types';
4
+ import { IAccessLogEntry, IEnhancedLoggerOptions, IHttpAccessLogger, IPerformanceMetrics } from './types';
3
5
  export declare class HttpAccessLogger implements IHttpAccessLogger {
4
6
  private logger;
5
7
  private options;
8
+ private requestIDManager;
9
+ private serverIp;
6
10
  constructor(logger: ApplicationLogger, options?: IEnhancedLoggerOptions);
7
11
  logAccess(entry: IAccessLogEntry): void;
8
- logPerformance(metrics: IPerformanceMetrics): void;
9
- logRequestData(data: any, level?: 'info' | 'warn' | 'error'): void;
12
+ logPerformance(opts: {
13
+ metrics: IPerformanceMetrics;
14
+ }): void;
15
+ logRequestData(data: AnyType, level: TLogLevel): void;
16
+ logRequestLegacy(level: TLogLevel, request: AnyType): void;
17
+ logResponseLegacy(opts: {
18
+ level: TLogLevel;
19
+ data: {
20
+ request: AnyType;
21
+ response: AnyType;
22
+ result: AnyType;
23
+ error: AnyType;
24
+ startTime: [number, number];
25
+ };
26
+ }): void;
10
27
  private formatAccessLog;
28
+ private formatLegacyAccessLog;
11
29
  private sanitizeRequestData;
12
- static createMiddleware(httpLogger: HttpAccessLogger): (req: any, res: any, next: () => void) => void;
30
+ private getServerIp;
31
+ private getMainFilePackageName;
32
+ private getClientIp;
33
+ static createMiddleware(httpLogger: HttpAccessLogger): (req: AnyType, res: AnyType, next: () => void) => void;
13
34
  }
14
35
  //# sourceMappingURL=access-logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"access-logger.d.ts","sourceRoot":"","sources":["../../../../src/helpers/logger/http/access-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAKjB,qBAAa,gBAAiB,YAAW,iBAAiB;IACxD,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,OAAO,CAAyB;gBAE5B,MAAM,EAAE,iBAAiB,EAAE,OAAO,GAAE,sBAA2B;IAW3E,SAAS,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAYvC,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAYlD,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,GAAE,MAAM,GAAG,MAAM,GAAG,OAAgB,GAAG,IAAI;IAkB1E,OAAO,CAAC,eAAe;I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