@tc-libs/http-log 3.5.0 → 3.6.1

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 (2) hide show
  1. package/README.md +76 -6
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,11 +1,81 @@
1
- # http-log
1
+ # @tc-libs/http-log
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ Logging HTTP middleware/interceptor oriented.
4
4
 
5
- ## Building
5
+ Il package copre due cose:
6
6
 
7
- Run `nx build http-log` to build the library.
7
+ - middleware automatici che loggano richieste/risposte
8
+ - `LoggerService` per salvare log HTTP strutturati su repository
8
9
 
9
- ## Running unit tests
10
+ ## Registrazione
10
11
 
11
- Run `nx test http-log` to execute the unit tests via [Jest](https://jestjs.io).
12
+ ```ts
13
+ HttpLogModule.register(
14
+ {
15
+ http: {
16
+ logReqParams: true,
17
+ logReqBody: true,
18
+ logResBody: false,
19
+ logHeaders: false,
20
+ writeIntoFile: true,
21
+ writeIntoConsole: true,
22
+ maxFiles: 14,
23
+ maxSize: '10M',
24
+ },
25
+ },
26
+ true,
27
+ );
28
+ ```
29
+
30
+ ## Middleware
31
+
32
+ Il modulo applica globalmente:
33
+
34
+ - `HttpLogResponseMiddleware`
35
+ - `HttpLogMiddleware`
36
+ - `HttpLogWriteIntoConsoleMiddleware`
37
+ - `HttpLogWriteIntoFileMiddleware`
38
+
39
+ Quindi basta importarlo per iniziare a raccogliere log HTTP.
40
+
41
+ ## Decorator `Logger`
42
+
43
+ Per log applicativi o endpoint-specific puoi usare:
44
+
45
+ ```ts
46
+ @Logger('USER_CREATE')
47
+ @Post()
48
+ create() {}
49
+ ```
50
+
51
+ Il decorator aggancia `LoggerInterceptor` e salva metadata sull'azione.
52
+
53
+ ## `LoggerService`
54
+
55
+ Metodi principali:
56
+
57
+ - `info(dto)`
58
+ - `debug(dto)`
59
+ - `warn(dto)`
60
+ - `fatal(dto)`
61
+ - `raw(dto)`
62
+
63
+ Esempio:
64
+
65
+ ```ts
66
+ await this.loggerService.info({
67
+ action: 'USER_LOGIN',
68
+ description: 'Login success',
69
+ requestId,
70
+ method: 'POST',
71
+ path: '/auth/login',
72
+ statusCode: 200,
73
+ });
74
+ ```
75
+
76
+ ## Sviluppo
77
+
78
+ ```bash
79
+ nx build http-log
80
+ nx test http-log
81
+ ```
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@tc-libs/http-log",
3
- "version": "3.5.0",
3
+ "version": "3.6.1",
4
4
  "dependencies": {
5
- "@tc-libs/authentication": "3.5.0",
6
- "@tc-libs/request": "3.5.0",
7
- "@tc-libs/helper": "3.5.0",
8
- "@tc-libs/database": "3.5.0",
9
- "@tc-libs/app-cache": "3.5.0",
5
+ "@tc-libs/authentication": "3.6.1",
6
+ "@tc-libs/request": "3.6.1",
7
+ "@tc-libs/helper": "3.6.1",
8
+ "@tc-libs/database": "3.6.1",
9
+ "@tc-libs/app-cache": "3.6.1",
10
10
  "@nestjs/common": "^11.0.12",
11
11
  "morgan": "^1.10.0",
12
12
  "rotating-file-stream": "^3.2.7",