@aomex/http-access-log 0.0.0-stage → 3.30.8-alpha.62.sha-92b25bb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,691 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [3.30.7](https://github.com/aomex/aomex/compare/v3.30.6...v3.30.7) (2026-11-01)
7
+
8
+ **Note:** Version bump only for package @aomex/http-logger
9
+
10
+
11
+
12
+
13
+
14
+ ## [3.30.6](https://github.com/aomex/aomex/compare/v3.30.5...v3.30.6) (2026-10-19)
15
+
16
+ **Note:** Version bump only for package @aomex/http-logger
17
+
18
+
19
+
20
+
21
+
22
+ ## [3.30.5](https://github.com/aomex/aomex/compare/v3.30.4...v3.30.5) (2026-06-16)
23
+
24
+ **Note:** Version bump only for package @aomex/http-logger
25
+
26
+
27
+
28
+
29
+
30
+ ## [3.30.4](https://github.com/aomex/aomex/compare/v3.30.3...v3.30.4) (2026-01-21)
31
+
32
+ **Note:** Version bump only for package @aomex/http-logger
33
+
34
+
35
+
36
+
37
+
38
+ ## [3.30.3](https://github.com/aomex/aomex/compare/v3.30.2...v3.30.3) (2025-12-01)
39
+
40
+ **Note:** Version bump only for package @aomex/http-logger
41
+
42
+
43
+
44
+
45
+
46
+ ## [3.30.2](https://github.com/aomex/aomex/compare/v3.30.1...v3.30.2) (2025-12-01)
47
+
48
+ **Note:** Version bump only for package @aomex/http-logger
49
+
50
+
51
+
52
+
53
+
54
+ ## [3.30.1](https://github.com/aomex/aomex/compare/v3.30.0...v3.30.1) (2025-12-01)
55
+
56
+ **Note:** Version bump only for package @aomex/http-logger
57
+
58
+
59
+
60
+
61
+
62
+ # [3.30.0](https://github.com/aomex/aomex/compare/v3.29.2...v3.30.0) (2025-11-30)
63
+
64
+ **Note:** Version bump only for package @aomex/http-logger
65
+
66
+
67
+
68
+
69
+
70
+ ## [3.29.2](https://github.com/aomex/aomex/compare/v3.29.1...v3.29.2) (2025-08-25)
71
+
72
+ **Note:** Version bump only for package @aomex/http-logger
73
+
74
+
75
+
76
+
77
+
78
+ ## [3.29.1](https://github.com/aomex/aomex/compare/v3.29.0...v3.29.1) (2025-07-26)
79
+
80
+ **Note:** Version bump only for package @aomex/http-logger
81
+
82
+
83
+
84
+
85
+
86
+ # [3.29.0](https://github.com/aomex/aomex/compare/v3.28.3...v3.29.0) (2025-07-17)
87
+
88
+ **Note:** Version bump only for package @aomex/http-logger
89
+
90
+
91
+
92
+
93
+
94
+ ## [3.28.3](https://github.com/aomex/aomex/compare/v3.28.2...v3.28.3) (2025-07-10)
95
+
96
+ **Note:** Version bump only for package @aomex/http-logger
97
+
98
+
99
+
100
+
101
+
102
+ ## [3.28.2](https://github.com/aomex/aomex/compare/v3.28.1...v3.28.2) (2025-07-09)
103
+
104
+ **Note:** Version bump only for package @aomex/http-logger
105
+
106
+
107
+
108
+
109
+
110
+ ## [3.28.1](https://github.com/aomex/aomex/compare/v3.28.0...v3.28.1) (2025-07-08)
111
+
112
+ **Note:** Version bump only for package @aomex/http-logger
113
+
114
+
115
+
116
+
117
+
118
+ # [3.28.0](https://github.com/aomex/aomex/compare/v3.27.4...v3.28.0) (2025-07-08)
119
+
120
+ **Note:** Version bump only for package @aomex/http-logger
121
+
122
+
123
+
124
+
125
+
126
+ ## [3.27.4](https://github.com/aomex/aomex/compare/v3.27.3...v3.27.4) (2025-06-29)
127
+
128
+ **Note:** Version bump only for package @aomex/http-logger
129
+
130
+
131
+
132
+
133
+
134
+ ## [3.27.3](https://github.com/aomex/aomex/compare/v3.27.2...v3.27.3) (2025-06-29)
135
+
136
+ **Note:** Version bump only for package @aomex/http-logger
137
+
138
+
139
+
140
+
141
+
142
+ ## [3.27.2](https://github.com/aomex/aomex/compare/v3.27.1...v3.27.2) (2025-06-04)
143
+
144
+ **Note:** Version bump only for package @aomex/http-logger
145
+
146
+
147
+
148
+
149
+
150
+ ## [3.27.1](https://github.com/aomex/aomex/compare/v3.27.0...v3.27.1) (2025-05-22)
151
+
152
+ **Note:** Version bump only for package @aomex/http-logger
153
+
154
+
155
+
156
+
157
+
158
+ # [3.27.0](https://github.com/aomex/aomex/compare/v3.26.0...v3.27.0) (2025-05-03)
159
+
160
+ **Note:** Version bump only for package @aomex/http-logger
161
+
162
+
163
+
164
+
165
+
166
+ # [3.26.0](https://github.com/aomex/aomex/compare/v3.25.0...v3.26.0) (2025-05-03)
167
+
168
+ **Note:** Version bump only for package @aomex/http-logger
169
+
170
+
171
+
172
+
173
+
174
+ # [3.25.0](https://github.com/aomex/aomex/compare/v3.24.0...v3.25.0) (2025-04-22)
175
+
176
+ **Note:** Version bump only for package @aomex/http-logger
177
+
178
+
179
+
180
+
181
+
182
+ # [3.24.0](https://github.com/aomex/aomex/compare/v3.23.3...v3.24.0) (2025-04-20)
183
+
184
+ **Note:** Version bump only for package @aomex/http-logger
185
+
186
+
187
+
188
+
189
+
190
+ ## [3.23.3](https://github.com/aomex/aomex/compare/v3.23.2...v3.23.3) (2025-04-18)
191
+
192
+ **Note:** Version bump only for package @aomex/http-logger
193
+
194
+
195
+
196
+
197
+
198
+ ## [3.23.2](https://github.com/aomex/aomex/compare/v3.23.1...v3.23.2) (2025-04-18)
199
+
200
+ **Note:** Version bump only for package @aomex/http-logger
201
+
202
+
203
+
204
+
205
+
206
+ ## [3.23.1](https://github.com/aomex/aomex/compare/v3.23.0...v3.23.1) (2025-04-18)
207
+
208
+ **Note:** Version bump only for package @aomex/http-logger
209
+
210
+
211
+
212
+
213
+
214
+ # [3.23.0](https://github.com/aomex/aomex/compare/v3.22.0...v3.23.0) (2025-04-16)
215
+
216
+ **Note:** Version bump only for package @aomex/http-logger
217
+
218
+
219
+
220
+
221
+
222
+ # [3.22.0](https://github.com/aomex/aomex/compare/v3.21.1...v3.22.0) (2025-04-07)
223
+
224
+ **Note:** Version bump only for package @aomex/http-logger
225
+
226
+
227
+
228
+
229
+
230
+ ## [3.21.1](https://github.com/aomex/aomex/compare/v3.21.0...v3.21.1) (2025-04-06)
231
+
232
+ **Note:** Version bump only for package @aomex/http-logger
233
+
234
+
235
+
236
+
237
+
238
+ # [3.21.0](https://github.com/aomex/aomex/compare/v3.20.0...v3.21.0) (2025-04-06)
239
+
240
+ **Note:** Version bump only for package @aomex/http-logger
241
+
242
+
243
+
244
+
245
+
246
+ # [3.20.0](https://github.com/aomex/aomex/compare/v3.19.2...v3.20.0) (2025-04-05)
247
+
248
+ **Note:** Version bump only for package @aomex/http-logger
249
+
250
+
251
+
252
+
253
+
254
+ ## [3.19.2](https://github.com/aomex/aomex/compare/v3.19.1...v3.19.2) (2025-04-05)
255
+
256
+ **Note:** Version bump only for package @aomex/http-logger
257
+
258
+
259
+
260
+
261
+
262
+ ## [3.19.1](https://github.com/aomex/aomex/compare/v3.19.0...v3.19.1) (2025-04-05)
263
+
264
+ **Note:** Version bump only for package @aomex/http-logger
265
+
266
+
267
+
268
+
269
+
270
+ # [3.19.0](https://github.com/aomex/aomex/compare/v3.18.0...v3.19.0) (2025-04-05)
271
+
272
+ **Note:** Version bump only for package @aomex/http-logger
273
+
274
+
275
+
276
+
277
+
278
+ # [3.18.0](https://github.com/aomex/aomex/compare/v3.17.3...v3.18.0) (2025-04-03)
279
+
280
+ **Note:** Version bump only for package @aomex/http-logger
281
+
282
+
283
+
284
+
285
+
286
+ ## [3.17.3](https://github.com/aomex/aomex/compare/v3.17.2...v3.17.3) (2025-03-26)
287
+
288
+
289
+ ### Bug Fixes
290
+
291
+ * 内部依赖使用固定版本号 ([aa70c2a](https://github.com/aomex/aomex/commit/aa70c2ad444414ec6619b9579ad8037a7191a86f))
292
+
293
+
294
+
295
+
296
+
297
+ ## [3.17.2](https://github.com/aomex/aomex/compare/v3.17.1...v3.17.2) (2025-03-26)
298
+
299
+ **Note:** Version bump only for package @aomex/http-logger
300
+
301
+
302
+
303
+
304
+
305
+ ## [3.17.1](https://github.com/aomex/aomex/compare/v3.17.0...v3.17.1) (2025-03-09)
306
+
307
+ **Note:** Version bump only for package @aomex/http-logger
308
+
309
+
310
+
311
+
312
+
313
+ # [3.17.0](https://github.com/aomex/aomex/compare/v3.16.0...v3.17.0) (2025-03-09)
314
+
315
+
316
+ ### Features
317
+
318
+ * **http-logger:** 增加disable属性禁用日志 ([8d43283](https://github.com/aomex/aomex/commit/8d43283b00e5df9e398655b5e5b78049cd20083a))
319
+ * **logger:** 独立安装 ([9a3f444](https://github.com/aomex/aomex/commit/9a3f4446ba7dd2da9a7f52eec8891624e9208435))
320
+
321
+
322
+
323
+
324
+
325
+ # [3.16.0](https://github.com/aomex/aomex/compare/v3.15.1...v3.16.0) (2025-03-09)
326
+
327
+ **Note:** Version bump only for package @aomex/http-logger
328
+
329
+
330
+
331
+
332
+
333
+ ## [3.15.1](https://github.com/aomex/aomex/compare/v3.15.0...v3.15.1) (2025-02-09)
334
+
335
+ **Note:** Version bump only for package @aomex/http-logger
336
+
337
+
338
+
339
+
340
+
341
+ # [3.15.0](https://github.com/aomex/aomex/compare/v3.14.2...v3.15.0) (2025-02-09)
342
+
343
+ **Note:** Version bump only for package @aomex/http-logger
344
+
345
+
346
+
347
+
348
+
349
+ ## [3.14.2](https://github.com/aomex/aomex/compare/v3.14.1...v3.14.2) (2025-01-14)
350
+
351
+ **Note:** Version bump only for package @aomex/http-logger
352
+
353
+
354
+
355
+
356
+
357
+ ## [3.14.1](https://github.com/aomex/aomex/compare/v3.14.0...v3.14.1) (2025-01-09)
358
+
359
+ **Note:** Version bump only for package @aomex/http-logger
360
+
361
+
362
+
363
+
364
+
365
+ # [3.14.0](https://github.com/aomex/aomex/compare/v3.13.1...v3.14.0) (2025-01-02)
366
+
367
+ **Note:** Version bump only for package @aomex/http-logger
368
+
369
+
370
+
371
+
372
+
373
+ ## [3.13.1](https://github.com/aomex/aomex/compare/v3.13.0...v3.13.1) (2024-12-29)
374
+
375
+ **Note:** Version bump only for package @aomex/http-logger
376
+
377
+
378
+
379
+
380
+
381
+ # [3.13.0](https://github.com/aomex/aomex/compare/v3.12.1...v3.13.0) (2024-12-27)
382
+
383
+ **Note:** Version bump only for package @aomex/http-logger
384
+
385
+
386
+
387
+
388
+
389
+ ## [3.12.1](https://github.com/aomex/aomex/compare/v3.12.0...v3.12.1) (2024-12-19)
390
+
391
+ **Note:** Version bump only for package @aomex/http-logger
392
+
393
+
394
+
395
+
396
+
397
+ # [3.12.0](https://github.com/aomex/aomex/compare/v3.11.0...v3.12.0) (2024-11-07)
398
+
399
+ **Note:** Version bump only for package @aomex/http-logger
400
+
401
+
402
+
403
+
404
+
405
+ # [3.11.0](https://github.com/aomex/aomex/compare/v3.10.0...v3.11.0) (2024-11-07)
406
+
407
+ **Note:** Version bump only for package @aomex/http-logger
408
+
409
+
410
+
411
+
412
+
413
+ # [3.10.0](https://github.com/aomex/aomex/compare/v3.9.0...v3.10.0) (2024-11-02)
414
+
415
+
416
+ ### Features
417
+
418
+ * **logger:** timestamp使用日期类型 ([26a5931](https://github.com/aomex/aomex/commit/26a5931ca0a9dfdb5a7abcdfd967092e5334aa04))
419
+
420
+
421
+
422
+
423
+
424
+ # [3.9.0](https://github.com/aomex/aomex/compare/v3.8.1...v3.9.0) (2024-10-30)
425
+
426
+
427
+ ### Features
428
+
429
+ * **http-logger:** 请求日志简化为一条 ([71a9c91](https://github.com/aomex/aomex/commit/71a9c91df80adbfb87ca07b25b52c3b430ad1b12))
430
+
431
+
432
+
433
+
434
+
435
+ ## [3.8.1](https://github.com/aomex/aomex/compare/v3.8.0...v3.8.1) (2024-10-26)
436
+
437
+ **Note:** Version bump only for package @aomex/http-logger
438
+
439
+
440
+
441
+
442
+
443
+ # [3.8.0](https://github.com/aomex/aomex/compare/v3.7.2...v3.8.0) (2024-10-26)
444
+
445
+ **Note:** Version bump only for package @aomex/http-logger
446
+
447
+
448
+
449
+
450
+
451
+ ## [3.7.2](https://github.com/aomex/aomex/compare/v3.7.1...v3.7.2) (2024-10-22)
452
+
453
+ **Note:** Version bump only for package @aomex/http-logger
454
+
455
+
456
+
457
+
458
+
459
+ ## [3.7.1](https://github.com/aomex/aomex/compare/v3.7.0...v3.7.1) (2024-10-22)
460
+
461
+ **Note:** Version bump only for package @aomex/http-logger
462
+
463
+
464
+
465
+
466
+
467
+ # [3.7.0](https://github.com/aomex/aomex/compare/v3.6.0...v3.7.0) (2024-10-19)
468
+
469
+ **Note:** Version bump only for package @aomex/http-logger
470
+
471
+
472
+
473
+
474
+
475
+ # [3.6.0](https://github.com/aomex/aomex/compare/v3.5.0...v3.6.0) (2024-10-17)
476
+
477
+ **Note:** Version bump only for package @aomex/http-logger
478
+
479
+
480
+
481
+
482
+
483
+ # [3.5.0](https://github.com/aomex/aomex/compare/v3.4.2...v3.5.0) (2024-10-16)
484
+
485
+ **Note:** Version bump only for package @aomex/http-logger
486
+
487
+
488
+
489
+
490
+
491
+ ## [3.4.2](https://github.com/aomex/aomex/compare/v3.4.1...v3.4.2) (2024-10-07)
492
+
493
+ **Note:** Version bump only for package @aomex/http-logger
494
+
495
+
496
+
497
+
498
+
499
+ ## [3.4.1](https://github.com/aomex/aomex/compare/v3.4.0...v3.4.1) (2024-10-06)
500
+
501
+ **Note:** Version bump only for package @aomex/http-logger
502
+
503
+
504
+
505
+
506
+
507
+ # [3.4.0](https://github.com/aomex/aomex/compare/v3.3.0...v3.4.0) (2024-10-04)
508
+
509
+ **Note:** Version bump only for package @aomex/http-logger
510
+
511
+
512
+
513
+
514
+
515
+ # [3.3.0](https://github.com/aomex/aomex/compare/v3.2.4...v3.3.0) (2024-09-26)
516
+
517
+ **Note:** Version bump only for package @aomex/http-logger
518
+
519
+
520
+
521
+
522
+
523
+ ## [3.2.4](https://github.com/aomex/aomex/compare/v3.2.3...v3.2.4) (2024-09-25)
524
+
525
+ **Note:** Version bump only for package @aomex/http-logger
526
+
527
+
528
+
529
+
530
+
531
+ ## [3.2.3](https://github.com/aomex/aomex/compare/v3.2.2...v3.2.3) (2024-09-25)
532
+
533
+ **Note:** Version bump only for package @aomex/http-logger
534
+
535
+
536
+
537
+
538
+
539
+ ## [3.2.2](https://github.com/aomex/aomex/compare/v3.2.1...v3.2.2) (2024-09-19)
540
+
541
+ **Note:** Version bump only for package @aomex/http-logger
542
+
543
+
544
+
545
+
546
+
547
+ ## [3.2.1](https://github.com/aomex/aomex/compare/v3.2.0...v3.2.1) (2024-09-17)
548
+
549
+ **Note:** Version bump only for package @aomex/http-logger
550
+
551
+
552
+
553
+
554
+
555
+ # [3.2.0](https://github.com/aomex/aomex/compare/v3.1.1...v3.2.0) (2024-09-17)
556
+
557
+ **Note:** Version bump only for package @aomex/http-logger
558
+
559
+
560
+
561
+
562
+
563
+ ## [3.1.1](https://github.com/aomex/aomex/compare/v3.1.0...v3.1.1) (2024-09-13)
564
+
565
+ **Note:** Version bump only for package @aomex/http-logger
566
+
567
+
568
+
569
+
570
+
571
+ # [3.1.0](https://github.com/aomex/aomex/compare/v3.0.0...v3.1.0) (2024-09-13)
572
+
573
+
574
+ ### Bug Fixes
575
+
576
+ * update peer deps ([98b7c10](https://github.com/aomex/aomex/commit/98b7c10068a3c62a0361b1b43a86728a7d445ab5))
577
+
578
+
579
+
580
+
581
+
582
+
583
+
584
+ # [2.2.0](https://github.com/aomex/aomex/compare/v2.1.0...v2.2.0) (2024-08-05)
585
+
586
+ **Note:** Version bump only for package @aomex/http-logger
587
+
588
+
589
+
590
+
591
+
592
+ # [2.1.0](https://github.com/aomex/aomex/compare/v2.0.2...v2.1.0) (2024-07-28)
593
+
594
+ **Note:** Version bump only for package @aomex/http-logger
595
+
596
+
597
+
598
+
599
+
600
+ ## [2.0.2](https://github.com/aomex/aomex/compare/v2.0.1...v2.0.2) (2024-07-27)
601
+
602
+ **Note:** Version bump only for package @aomex/http-logger
603
+
604
+
605
+
606
+
607
+
608
+ ## [2.0.1](https://github.com/aomex/aomex/compare/v2.0.0...v2.0.1) (2024-07-26)
609
+
610
+
611
+ ### Bug Fixes
612
+
613
+ * 未更新peerDependencies ([0492453](https://github.com/aomex/aomex/commit/0492453d5a748aa6dd2047622a19a86dc7b6036e))
614
+
615
+
616
+
617
+
618
+
619
+ # [2.0.0](https://github.com/aomex/aomex/compare/v1.7.0...v2.0.0) (2024-07-26)
620
+
621
+ **Note:** Version bump only for package @aomex/http-logger
622
+
623
+
624
+
625
+
626
+
627
+ # [1.7.0](https://github.com/aomex/aomex/compare/v1.6.0...v1.7.0) (2024-07-13)
628
+
629
+ **Note:** Version bump only for package @aomex/http-logger
630
+
631
+
632
+
633
+
634
+
635
+ # [1.6.0](https://github.com/aomex/aomex/compare/v1.5.1...v1.6.0) (2024-07-05)
636
+
637
+ **Note:** Version bump only for package @aomex/http-logger
638
+
639
+
640
+
641
+
642
+
643
+ ## [1.5.1](https://github.com/aomex/aomex/compare/v1.5.0...v1.5.1) (2024-07-04)
644
+
645
+ **Note:** Version bump only for package @aomex/http-logger
646
+
647
+
648
+
649
+
650
+
651
+ # [1.5.0](https://github.com/aomex/aomex/compare/v1.4.0...v1.5.0) (2024-07-04)
652
+
653
+ **Note:** Version bump only for package @aomex/http-logger
654
+
655
+
656
+
657
+
658
+
659
+ # [1.4.0](https://github.com/aomex/aomex/compare/v1.3.0...v1.4.0) (2024-06-29)
660
+
661
+ **Note:** Version bump only for package @aomex/http-logger
662
+
663
+
664
+
665
+
666
+
667
+ # [1.3.0](https://github.com/aomex/aomex/compare/v1.2.0...v1.3.0) (2024-06-28)
668
+
669
+
670
+ ### Features
671
+
672
+ * **core:** 删除中间件链条概念 ([12f42e6](https://github.com/aomex/aomex/commit/12f42e6ba15f3118b98f5ff31832121b1b2b9896))
673
+
674
+
675
+
676
+
677
+
678
+ # [1.2.0](https://github.com/aomex/aomex/compare/v1.1.0...v1.2.0) (2024-06-27)
679
+
680
+ **Note:** Version bump only for package @aomex/http-logger
681
+
682
+
683
+
684
+
685
+
686
+ # 1.1.0 (2024-06-27)
687
+
688
+
689
+ ### Features
690
+
691
+ * 初始化 ([3350159](https://github.com/aomex/aomex/commit/3350159454ad230e6d910405f907293b059b1f49))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-2024 geekact
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # Temporary Holding Version
1
+ # @aomex/http-access-log
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 文档:https://aomex.js.org
@@ -0,0 +1,40 @@
1
+ import { Transport } from "@aomex/logger";
2
+ import { WebContext, WebMiddleware } from "@aomex/web";
3
+ export interface HttpAccessLogOptions {
4
+ /**
5
+ * 是否禁用请求日志。默认:`false`
6
+ */
7
+ disabled?: boolean;
8
+ /**
9
+ * 响应输出格式,建议使用 **HttpAccessLogToken** 拼接。默认值:`[ip] [method] [url] [statusCode] [duration] [contentLength]`
10
+ */
11
+ format?: string;
12
+ /**
13
+ * 日志输出端口。默认使用 `ConsoleTransport`。
14
+ */
15
+ transports?: Transport[];
16
+ /**
17
+ * 自定义关键词
18
+ * ```
19
+ * httpAccessLog({
20
+ * format: ' [request] [time] [href]',
21
+ * customTokens: {
22
+ * href: (ctx) => ctx.request.href,
23
+ * },
24
+ * })
25
+ * ```
26
+ */
27
+ customTokens?: {
28
+ [key: string]: (ctx: WebContext) => string | Promise<string>;
29
+ };
30
+ }
31
+ export declare const httpAccessLog: (options?: HttpAccessLogOptions) => WebMiddleware;
32
+ export declare enum HttpAccessLogToken {
33
+ method = "[method]",
34
+ url = "[url]",
35
+ statusCode = "[statusCode]",
36
+ contentLength = "[contentLength]",
37
+ contentType = "[contentType]",
38
+ duration = "[duration]",
39
+ ip = "[ip]"
40
+ }
package/dist/index.js ADDED
@@ -0,0 +1,121 @@
1
+ import { middleware } from "@aomex/common";
2
+ import { BaseLoggerService, ConsoleTransport } from "@aomex/logger";
3
+ import stream from "node:stream";
4
+ import prettyTime from "pretty-time";
5
+ import { bytes } from "@aomex/internal-tools";
6
+ import { statuses } from "@aomex/web";
7
+ import { styleText } from "node:util";
8
+ // src/http-access-log-token.ts
9
+ let HttpAccessLogToken = /* @__PURE__ */ function(HttpAccessLogToken) {
10
+ HttpAccessLogToken["method"] = "[method]";
11
+ HttpAccessLogToken["url"] = "[url]";
12
+ HttpAccessLogToken["statusCode"] = "[statusCode]";
13
+ HttpAccessLogToken["contentLength"] = "[contentLength]";
14
+ HttpAccessLogToken["contentType"] = "[contentType]";
15
+ HttpAccessLogToken["duration"] = "[duration]";
16
+ HttpAccessLogToken["ip"] = "[ip]";
17
+ return HttpAccessLogToken;
18
+ }({});
19
+ // src/counter.ts
20
+ var Counter = class extends stream.Transform {
21
+ length = 0;
22
+ _transform(chunk, _encoding, callback) {
23
+ this.length += chunk.length;
24
+ this.push(chunk);
25
+ callback();
26
+ }
27
+ };
28
+ // src/replace-token.ts
29
+ const colorCodes = {
30
+ 7: "magenta",
31
+ 5: "red",
32
+ 4: "yellow",
33
+ 3: "cyan",
34
+ 2: "green",
35
+ 1: "green",
36
+ 0: "yellow"
37
+ };
38
+ const pattern = /\[[^\[\]]+\]/g;
39
+ const replaceToken = async (opts) => {
40
+ const { message, startTime, request, response = {}, tokens = {} } = opts;
41
+ const { method, url } = request;
42
+ const { contentLength, contentType = "-", statusCode = 404 } = response;
43
+ let formatted = message;
44
+ for (let match of message.matchAll(pattern)) {
45
+ const tokenWithBrackets = match[0];
46
+ const token = tokenWithBrackets.slice(1, -1);
47
+ const replace = (data) => {
48
+ formatted = formatted.replaceAll(tokenWithBrackets, data);
49
+ };
50
+ if (tokens[token]) replace(await tokens[token]());
51
+ switch (`[${token}]`) {
52
+ case "[method]":
53
+ replace(styleText("bold", method));
54
+ break;
55
+ case "[url]":
56
+ replace(styleText("gray", url));
57
+ break;
58
+ case "[statusCode]":
59
+ const c = colorCodes[statusCode / 100 | 0] || colorCodes[0];
60
+ replace(styleText(c, statusCode.toString()));
61
+ break;
62
+ case "[contentLength]":
63
+ replace(styleText("gray", statuses.empty[statusCode] || contentLength === 0 ? "0" : contentLength == null ? "-" : bytes(contentLength).toLowerCase()));
64
+ break;
65
+ case "[contentType]":
66
+ replace(styleText("gray", contentType));
67
+ break;
68
+ case "[duration]":
69
+ replace(styleText("gray", prettyTime(process.hrtime(startTime))));
70
+ break;
71
+ case "[ip]": replace(styleText("gray", request.ip));
72
+ }
73
+ }
74
+ return formatted;
75
+ };
76
+ // src/http-access-log.ts
77
+ var HttpAccessLogService = class extends BaseLoggerService {
78
+ entries;
79
+ constructor(entries) {
80
+ super();
81
+ this.entries = entries;
82
+ }
83
+ createTransports() {
84
+ return this.entries;
85
+ }
86
+ };
87
+ const httpAccessLog = (options = {}) => {
88
+ const { disabled = false, customTokens } = options;
89
+ const format = options.format || `[ip] [method] [url] [statusCode] [duration] [contentLength]`;
90
+ const logger = new HttpAccessLogService((options.transports && options.transports.length > 0 ? options.transports : [new ConsoleTransport()]).map((transport) => ({ transport })));
91
+ return middleware.web(async (ctx, next) => {
92
+ if (disabled) return next();
93
+ const start = process.hrtime();
94
+ const tokens = customTokens ? Object.fromEntries(Object.entries(customTokens).map(([key, value]) => {
95
+ return [key, value.bind(null, ctx)];
96
+ })) : {};
97
+ try {
98
+ await next();
99
+ } finally {
100
+ const { response, response: { body } } = ctx;
101
+ let counter;
102
+ if (body instanceof stream.Readable && body.readable) ctx.send(body.pipe(counter = new Counter()));
103
+ response.once("close", async () => {
104
+ logger.info(await replaceToken({
105
+ message: format,
106
+ tokens,
107
+ startTime: start,
108
+ request: ctx.request,
109
+ response: {
110
+ statusCode: response.statusCode,
111
+ contentType: response.contentType,
112
+ contentLength: counter ? counter.length : response.contentLength
113
+ }
114
+ }));
115
+ });
116
+ }
117
+ });
118
+ };
119
+ export { HttpAccessLogToken, httpAccessLog };
120
+
121
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/http-access-log-token.ts","../src/counter.ts","../src/replace-token.ts","../src/http-access-log.ts"],"sourcesContent":["export enum HttpAccessLogToken {\n method = '[method]',\n url = '[url]',\n statusCode = '[statusCode]',\n contentLength = '[contentLength]',\n contentType = '[contentType]',\n duration = '[duration]',\n ip = '[ip]',\n}\n","import stream, { type TransformCallback } from 'node:stream';\n\nexport class Counter extends stream.Transform {\n public length: number = 0;\n\n override _transform(\n chunk: any,\n _encoding: BufferEncoding,\n callback: TransformCallback,\n ): void {\n this.length += chunk.length;\n this.push(chunk);\n callback();\n }\n}\n","import prettyTime from 'pretty-time';\nimport { bytes } from '@aomex/internal-tools';\nimport { statuses } from '@aomex/web';\nimport { HttpAccessLogToken } from './http-access-log-token';\nimport { styleText } from 'node:util';\n\nexport const colorCodes = <const>{\n 7: 'magenta',\n 5: 'red',\n 4: 'yellow',\n 3: 'cyan',\n 2: 'green',\n 1: 'green',\n 0: 'yellow',\n};\n\nconst pattern = /\\[[^\\[\\]]+\\]/g;\n\nexport const replaceToken = async (opts: {\n message: string;\n startTime: [number, number];\n tokens?: { [key: string]: () => string | Promise<string> };\n request: {\n method: string;\n url: string;\n ip: string;\n };\n response?: {\n statusCode?: number;\n contentType?: string;\n contentLength?: number;\n };\n}): Promise<string> => {\n const { message, startTime, request, response = {}, tokens = {} } = opts;\n const { method, url } = request;\n const { contentLength, contentType = '-', statusCode = 404 } = response;\n let formatted = message;\n\n for (let match of message.matchAll(pattern)) {\n const tokenWithBrackets = match[0];\n const token = tokenWithBrackets.slice(1, -1);\n\n const replace = (data: string) => {\n formatted = formatted.replaceAll(tokenWithBrackets, data);\n };\n\n if (tokens[token]) {\n replace(await tokens[token]!());\n }\n\n switch (`[${token}]`) {\n case HttpAccessLogToken.method:\n replace(styleText('bold', method));\n break;\n case HttpAccessLogToken.url:\n replace(styleText('gray', url));\n break;\n case HttpAccessLogToken.statusCode:\n const c =\n colorCodes[((statusCode / 100) | 0) as keyof typeof colorCodes] ||\n colorCodes[0]!;\n replace(styleText(c, statusCode.toString()));\n break;\n case HttpAccessLogToken.contentLength:\n replace(\n styleText(\n 'gray',\n statuses.empty[statusCode] || contentLength === 0\n ? '0'\n : contentLength == null\n ? '-'\n : bytes(contentLength).toLowerCase(),\n ),\n );\n break;\n case HttpAccessLogToken.contentType:\n replace(styleText('gray', contentType));\n break;\n case HttpAccessLogToken.duration:\n replace(styleText('gray', prettyTime(process.hrtime(startTime))));\n break;\n case HttpAccessLogToken.ip:\n replace(styleText('gray', request.ip));\n break;\n }\n }\n\n return formatted;\n};\n","import { middleware } from '@aomex/common';\nimport { BaseLoggerService, ConsoleTransport, type Transport } from '@aomex/logger';\nimport type { WebContext, WebMiddleware } from '@aomex/web';\nimport { HttpAccessLogToken } from './http-access-log-token';\nimport { Counter } from './counter';\nimport stream from 'node:stream';\nimport { replaceToken } from './replace-token';\n\nexport interface HttpAccessLogOptions {\n /**\n * 是否禁用请求日志。默认:`false`\n */\n disabled?: boolean;\n /**\n * 响应输出格式,建议使用 **HttpAccessLogToken** 拼接。默认值:`[ip] [method] [url] [statusCode] [duration] [contentLength]`\n */\n format?: string;\n /**\n * 日志输出端口。默认使用 `ConsoleTransport`。\n */\n transports?: Transport[];\n /**\n * 自定义关键词\n * ```\n * httpAccessLog({\n * format: ' [request] [time] [href]',\n * customTokens: {\n * href: (ctx) => ctx.request.href,\n * },\n * })\n * ```\n */\n customTokens?: { [key: string]: (ctx: WebContext) => string | Promise<string> };\n}\n\nclass HttpAccessLogService extends BaseLoggerService {\n constructor(private readonly entries: BaseLoggerService.TransportEntry[]) {\n super();\n }\n\n protected createTransports(): BaseLoggerService.TransportEntry[] {\n return this.entries;\n }\n}\n\nexport const httpAccessLog = (options: HttpAccessLogOptions = {}): WebMiddleware => {\n const { disabled = false, customTokens } = options;\n const format =\n options.format ||\n `${HttpAccessLogToken.ip} ${HttpAccessLogToken.method} ${HttpAccessLogToken.url} ${HttpAccessLogToken.statusCode} ${HttpAccessLogToken.duration} ${HttpAccessLogToken.contentLength}`;\n\n const transportList =\n options.transports && options.transports.length > 0\n ? options.transports\n : [new ConsoleTransport()];\n\n const logger = new HttpAccessLogService(\n transportList.map((transport) => ({ transport })),\n );\n\n return middleware.web(async (ctx, next) => {\n if (disabled) return next();\n\n const start = process.hrtime();\n const tokens = customTokens\n ? Object.fromEntries(\n Object.entries(customTokens).map(([key, value]) => {\n return [key, value.bind(null, ctx)];\n }),\n )\n : {};\n\n try {\n await next();\n } finally {\n const {\n response,\n response: { body },\n } = ctx;\n let counter: Counter | undefined;\n if (body instanceof stream.Readable && body.readable) {\n ctx.send(body.pipe((counter = new Counter())));\n }\n\n response.once('close', async () => {\n logger.info(\n await replaceToken({\n message: format,\n tokens,\n startTime: start,\n request: ctx.request,\n response: {\n statusCode: response.statusCode,\n contentType: response.contentType,\n contentLength: counter ? counter.length : response.contentLength,\n },\n }),\n );\n });\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA,IAAY,qBAAL,yBAAA,oBAAA;CACL,mBAAA,YAAA;CACA,mBAAA,SA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ACR,YAAY,SAAS;MACrB,aAAa,SAAS;MACtB,eAAe,UAAU,QAAQ,SAAS,SAAS;KACrD;IACF,CAAC,CACH;GACF,CAAC;EACH;CACF,CAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "@aomex/http-access-log",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "3.30.8-alpha.62.sha-92b25bb",
4
+ "description": "HTTP access log middleware",
5
+ "repository": "git@github.com:aomex/aomex.git",
6
+ "homepage": "https://aomex.js.org",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "sideEffects": false,
10
+ "scripts": {
11
+ "prepublishOnly": "tsdown"
12
+ },
13
+ "types": "src/index.ts",
14
+ "exports": "./src/index.ts",
15
+ "files": [
16
+ "dist",
17
+ "package.json",
18
+ "README.md",
19
+ "CHANGELOG.md"
20
+ ],
21
+ "publishConfig": {
22
+ "types": "dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "access": "public"
31
+ },
32
+ "peerDependencies": {
33
+ "@aomex/common": "^4.0.0",
34
+ "@aomex/web": "^4.0.0"
35
+ },
36
+ "dependencies": {
37
+ "@aomex/internal-tools": "3.30.8-alpha.62.sha-92b25bb",
38
+ "@aomex/logger": "3.30.8-alpha.62.sha-92b25bb",
39
+ "pretty-time": "^1.1.0"
40
+ },
41
+ "devDependencies": {
42
+ "@aomex/common": "3.30.8-alpha.62.sha-92b25bb",
43
+ "@aomex/web": "3.30.8-alpha.62.sha-92b25bb",
44
+ "@types/pretty-time": "^1.1.5"
45
+ },
46
+ "gitHead": "92b25bbcd6c3ae28160316117a74c88619b5bc8d"
47
+ }