@xylabs/express 7.0.8 → 8.0.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 (130) hide show
  1. package/README.md +1 -2061
  2. package/dist/node/index.d.ts +1 -8
  3. package/dist/node/index.d.ts.map +1 -1
  4. package/dist/node/index.mjs +2 -506
  5. package/dist/node/index.mjs.map +4 -4
  6. package/package.json +7 -22
  7. package/dist/node/Handler/RouteDefinition/RouteDefinition.d.ts +0 -10
  8. package/dist/node/Handler/RouteDefinition/RouteDefinition.d.ts.map +0 -1
  9. package/dist/node/Handler/RouteDefinition/addRouteDefinitions.d.ts +0 -9
  10. package/dist/node/Handler/RouteDefinition/addRouteDefinitions.d.ts.map +0 -1
  11. package/dist/node/Handler/RouteDefinition/index.d.ts +0 -3
  12. package/dist/node/Handler/RouteDefinition/index.d.ts.map +0 -1
  13. package/dist/node/Handler/StatusCodeHandlers/index.d.ts +0 -2
  14. package/dist/node/Handler/StatusCodeHandlers/index.d.ts.map +0 -1
  15. package/dist/node/Handler/StatusCodeHandlers/notImplemented.d.ts +0 -4
  16. package/dist/node/Handler/StatusCodeHandlers/notImplemented.d.ts.map +0 -1
  17. package/dist/node/Handler/asyncHandler.d.ts +0 -21
  18. package/dist/node/Handler/asyncHandler.d.ts.map +0 -1
  19. package/dist/node/Handler/errorToJsonHandler.d.ts +0 -11
  20. package/dist/node/Handler/errorToJsonHandler.d.ts.map +0 -1
  21. package/dist/node/Handler/index.d.ts +0 -5
  22. package/dist/node/Handler/index.d.ts.map +0 -1
  23. package/dist/node/HttpStatus.d.ts +0 -11
  24. package/dist/node/HttpStatus.d.ts.map +0 -1
  25. package/dist/node/HttpUtil/getHttpHeader.d.ts +0 -12
  26. package/dist/node/HttpUtil/getHttpHeader.d.ts.map +0 -1
  27. package/dist/node/HttpUtil/index.d.ts +0 -2
  28. package/dist/node/HttpUtil/index.d.ts.map +0 -1
  29. package/dist/node/Logger/LogFormats/LocalDev/index.d.ts +0 -2
  30. package/dist/node/Logger/LogFormats/LocalDev/index.d.ts.map +0 -1
  31. package/dist/node/Logger/LogFormats/LocalDev/logFormatLocalDev.d.ts +0 -4
  32. package/dist/node/Logger/LogFormats/LocalDev/logFormatLocalDev.d.ts.map +0 -1
  33. package/dist/node/Logger/LogFormats/Rollbar/index.d.ts +0 -2
  34. package/dist/node/Logger/LogFormats/Rollbar/index.d.ts.map +0 -1
  35. package/dist/node/Logger/LogFormats/Rollbar/logFormatRollbar.d.ts +0 -4
  36. package/dist/node/Logger/LogFormats/Rollbar/logFormatRollbar.d.ts.map +0 -1
  37. package/dist/node/Logger/LogFormats/Structured/index.d.ts +0 -2
  38. package/dist/node/Logger/LogFormats/Structured/index.d.ts.map +0 -1
  39. package/dist/node/Logger/LogFormats/Structured/logFormatStructured.d.ts +0 -4
  40. package/dist/node/Logger/LogFormats/Structured/logFormatStructured.d.ts.map +0 -1
  41. package/dist/node/Logger/LogFormats/index.d.ts +0 -4
  42. package/dist/node/Logger/LogFormats/index.d.ts.map +0 -1
  43. package/dist/node/Logger/LoggerMeta.d.ts +0 -3
  44. package/dist/node/Logger/LoggerMeta.d.ts.map +0 -1
  45. package/dist/node/Logger/LoggerOptions.d.ts +0 -8
  46. package/dist/node/Logger/LoggerOptions.d.ts.map +0 -1
  47. package/dist/node/Logger/LoggerVerbosity.d.ts +0 -3
  48. package/dist/node/Logger/LoggerVerbosity.d.ts.map +0 -1
  49. package/dist/node/Logger/Transports/Rollbar/RollbarTransport.d.ts +0 -12
  50. package/dist/node/Logger/Transports/Rollbar/RollbarTransport.d.ts.map +0 -1
  51. package/dist/node/Logger/Transports/Rollbar/canGetDefaultRollbarTransport.d.ts +0 -7
  52. package/dist/node/Logger/Transports/Rollbar/canGetDefaultRollbarTransport.d.ts.map +0 -1
  53. package/dist/node/Logger/Transports/Rollbar/getDefaultRollbarTransport.d.ts +0 -8
  54. package/dist/node/Logger/Transports/Rollbar/getDefaultRollbarTransport.d.ts.map +0 -1
  55. package/dist/node/Logger/Transports/Rollbar/index.d.ts +0 -4
  56. package/dist/node/Logger/Transports/Rollbar/index.d.ts.map +0 -1
  57. package/dist/node/Logger/Transports/index.d.ts +0 -2
  58. package/dist/node/Logger/Transports/index.d.ts.map +0 -1
  59. package/dist/node/Logger/WinstonVerbosity.d.ts +0 -6
  60. package/dist/node/Logger/WinstonVerbosity.d.ts.map +0 -1
  61. package/dist/node/Logger/WrappedWinstonLogger.d.ts +0 -17
  62. package/dist/node/Logger/WrappedWinstonLogger.d.ts.map +0 -1
  63. package/dist/node/Logger/getDefaultLogger.d.ts +0 -17
  64. package/dist/node/Logger/getDefaultLogger.d.ts.map +0 -1
  65. package/dist/node/Logger/getLogger.d.ts +0 -9
  66. package/dist/node/Logger/getLogger.d.ts.map +0 -1
  67. package/dist/node/Logger/index.d.ts +0 -12
  68. package/dist/node/Logger/index.d.ts.map +0 -1
  69. package/dist/node/Logger/toWinstonVerbosity.d.ts +0 -9
  70. package/dist/node/Logger/toWinstonVerbosity.d.ts.map +0 -1
  71. package/dist/node/Model/ExpressError.d.ts +0 -5
  72. package/dist/node/Model/ExpressError.d.ts.map +0 -1
  73. package/dist/node/Model/index.d.ts +0 -2
  74. package/dist/node/Model/index.d.ts.map +0 -1
  75. package/dist/node/Performance/Counters.d.ts +0 -9
  76. package/dist/node/Performance/Counters.d.ts.map +0 -1
  77. package/dist/node/Performance/Profiler.d.ts +0 -6
  78. package/dist/node/Performance/Profiler.d.ts.map +0 -1
  79. package/dist/node/Performance/index.d.ts +0 -3
  80. package/dist/node/Performance/index.d.ts.map +0 -1
  81. package/dist/node/Util/compactObject.d.ts +0 -7
  82. package/dist/node/Util/compactObject.d.ts.map +0 -1
  83. package/dist/node/Util/index.d.ts +0 -3
  84. package/dist/node/Util/index.d.ts.map +0 -1
  85. package/dist/node/Util/tryParse.d.ts +0 -7
  86. package/dist/node/Util/tryParse.d.ts.map +0 -1
  87. package/dist/node/Validation/index.d.ts +0 -2
  88. package/dist/node/Validation/index.d.ts.map +0 -1
  89. package/dist/node/Validation/requestHandlerValidator.d.ts +0 -31
  90. package/dist/node/Validation/requestHandlerValidator.d.ts.map +0 -1
  91. package/dist/node/middleware/caseInsensitiveRouting/caseInsensitiveRouting.d.ts +0 -14
  92. package/dist/node/middleware/caseInsensitiveRouting/caseInsensitiveRouting.d.ts.map +0 -1
  93. package/dist/node/middleware/caseInsensitiveRouting/index.d.ts +0 -2
  94. package/dist/node/middleware/caseInsensitiveRouting/index.d.ts.map +0 -1
  95. package/dist/node/middleware/customPoweredByHeader/customPoweredByHeader.d.ts +0 -16
  96. package/dist/node/middleware/customPoweredByHeader/customPoweredByHeader.d.ts.map +0 -1
  97. package/dist/node/middleware/customPoweredByHeader/index.d.ts +0 -2
  98. package/dist/node/middleware/customPoweredByHeader/index.d.ts.map +0 -1
  99. package/dist/node/middleware/index.d.ts +0 -6
  100. package/dist/node/middleware/index.d.ts.map +0 -1
  101. package/dist/node/middleware/jsonBodyParser/index.d.ts +0 -2
  102. package/dist/node/middleware/jsonBodyParser/index.d.ts.map +0 -1
  103. package/dist/node/middleware/jsonBodyParser/jsonBodyParser.d.ts +0 -33
  104. package/dist/node/middleware/jsonBodyParser/jsonBodyParser.d.ts.map +0 -1
  105. package/dist/node/middleware/metrics/counters.d.ts +0 -7
  106. package/dist/node/middleware/metrics/counters.d.ts.map +0 -1
  107. package/dist/node/middleware/metrics/index.d.ts +0 -3
  108. package/dist/node/middleware/metrics/index.d.ts.map +0 -1
  109. package/dist/node/middleware/metrics/responseProfiler.d.ts +0 -25
  110. package/dist/node/middleware/metrics/responseProfiler.d.ts.map +0 -1
  111. package/dist/node/middleware/standardResponses/getResponseMetadata.d.ts +0 -19
  112. package/dist/node/middleware/standardResponses/getResponseMetadata.d.ts.map +0 -1
  113. package/dist/node/middleware/standardResponses/index.d.ts +0 -5
  114. package/dist/node/middleware/standardResponses/index.d.ts.map +0 -1
  115. package/dist/node/middleware/standardResponses/jsonApi/error.d.ts +0 -51
  116. package/dist/node/middleware/standardResponses/jsonApi/error.d.ts.map +0 -1
  117. package/dist/node/middleware/standardResponses/jsonApi/index.d.ts +0 -6
  118. package/dist/node/middleware/standardResponses/jsonApi/index.d.ts.map +0 -1
  119. package/dist/node/middleware/standardResponses/jsonApi/links.d.ts +0 -10
  120. package/dist/node/middleware/standardResponses/jsonApi/links.d.ts.map +0 -1
  121. package/dist/node/middleware/standardResponses/jsonApi/relationship.d.ts +0 -43
  122. package/dist/node/middleware/standardResponses/jsonApi/relationship.d.ts.map +0 -1
  123. package/dist/node/middleware/standardResponses/jsonApi/resourceIdentifier.d.ts +0 -16
  124. package/dist/node/middleware/standardResponses/jsonApi/resourceIdentifier.d.ts.map +0 -1
  125. package/dist/node/middleware/standardResponses/jsonApi/response.d.ts +0 -50
  126. package/dist/node/middleware/standardResponses/jsonApi/response.d.ts.map +0 -1
  127. package/dist/node/middleware/standardResponses/standardErrors.d.ts +0 -11
  128. package/dist/node/middleware/standardResponses/standardErrors.d.ts.map +0 -1
  129. package/dist/node/middleware/standardResponses/standardResponses.d.ts +0 -27
  130. package/dist/node/middleware/standardResponses/standardResponses.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,2063 +1,3 @@
1
- [![logo][]](https://xylabs.com)
2
-
3
1
  # @xylabs/express
4
2
 
5
- [![npm][npm-badge]][npm-link]
6
- [![license][license-badge]][license-link]
7
-
8
- > SDK for base code for Api repos that use express and deploy on AWS ECS
9
-
10
- ## Install
11
-
12
- Using npm:
13
-
14
- ```sh
15
- npm install {{name}}
16
- ```
17
-
18
- Using yarn:
19
-
20
- ```sh
21
- yarn add {{name}}
22
- ```
23
-
24
- Using pnpm:
25
-
26
- ```sh
27
- pnpm add {{name}}
28
- ```
29
-
30
- Using bun:
31
-
32
- ```sh
33
- bun add {{name}}
34
- ```
35
-
36
-
37
- ## License
38
-
39
- See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
40
-
41
- ## Reference
42
-
43
- ### packages
44
-
45
- ### express
46
-
47
- ### .temp-typedoc
48
-
49
- ### classes
50
-
51
- ### <a id="Counters"></a>Counters
52
-
53
- [**@xylabs/express**](#../README)
54
-
55
- ***
56
-
57
- Static counter registry for tracking named numeric metrics.
58
-
59
- ## Constructors
60
-
61
- ### Constructor
62
-
63
- ```ts
64
- new Counters(): Counters;
65
- ```
66
-
67
- ### Returns
68
-
69
- `Counters`
70
-
71
- ## Properties
72
-
73
- ### counters
74
-
75
- ```ts
76
- static counters: Record<string, number> = {};
77
- ```
78
-
79
- ## Methods
80
-
81
- ### inc()
82
-
83
- ```ts
84
- static inc(name, count?): void;
85
- ```
86
-
87
- ### Parameters
88
-
89
- #### name
90
-
91
- `string`
92
-
93
- #### count?
94
-
95
- `number` = `1`
96
-
97
- ### Returns
98
-
99
- `void`
100
-
101
- ***
102
-
103
- ### max()
104
-
105
- ```ts
106
- static max(name, count): void;
107
- ```
108
-
109
- ### Parameters
110
-
111
- #### name
112
-
113
- `string`
114
-
115
- #### count
116
-
117
- `number`
118
-
119
- ### Returns
120
-
121
- `void`
122
-
123
- ***
124
-
125
- ### min()
126
-
127
- ```ts
128
- static min(name, count): void;
129
- ```
130
-
131
- ### Parameters
132
-
133
- #### name
134
-
135
- `string`
136
-
137
- #### count
138
-
139
- `number`
140
-
141
- ### Returns
142
-
143
- `void`
144
-
145
- ### <a id="Profiler"></a>Profiler
146
-
147
- [**@xylabs/express**](#../README)
148
-
149
- ***
150
-
151
- Measures and records the execution duration of async operations by name.
152
-
153
- ## Constructors
154
-
155
- ### Constructor
156
-
157
- ```ts
158
- new Profiler(): Profiler;
159
- ```
160
-
161
- ### Returns
162
-
163
- `Profiler`
164
-
165
- ## Properties
166
-
167
- ### stats
168
-
169
- ```ts
170
- stats: Record<string, number> = {};
171
- ```
172
-
173
- ## Methods
174
-
175
- ### profile()
176
-
177
- ```ts
178
- profile<T>(name, promise): Promise<T>;
179
- ```
180
-
181
- ### Type Parameters
182
-
183
- #### T
184
-
185
- `T`
186
-
187
- ### Parameters
188
-
189
- #### name
190
-
191
- `string`
192
-
193
- #### promise
194
-
195
- `Promise`\<`T`\>
196
-
197
- ### Returns
198
-
199
- `Promise`\<`T`\>
200
-
201
- ### <a id="WrappedWinstonLogger"></a>WrappedWinstonLogger
202
-
203
- [**@xylabs/express**](#../README)
204
-
205
- ***
206
-
207
- Wrap Winston logger methods to adapt to familiar
208
- console logging methods
209
-
210
- ## Implements
211
-
212
- - `Logger`
213
-
214
- ## Constructors
215
-
216
- ### Constructor
217
-
218
- ```ts
219
- new WrappedWinstonLogger(winston): WrappedWinstonLogger;
220
- ```
221
-
222
- ### Parameters
223
-
224
- #### winston
225
-
226
- `Logger`
227
-
228
- ### Returns
229
-
230
- `WrappedWinstonLogger`
231
-
232
- ## Properties
233
-
234
- ### winston
235
-
236
- ```ts
237
- protected readonly winston: Logger;
238
- ```
239
-
240
- ***
241
-
242
- ### debug
243
-
244
- ```ts
245
- debug: LogFunction;
246
- ```
247
-
248
- ### Implementation of
249
-
250
- ```ts
251
- Logger.debug
252
- ```
253
-
254
- ***
255
-
256
- ### error
257
-
258
- ```ts
259
- error: LogFunction;
260
- ```
261
-
262
- ### Implementation of
263
-
264
- ```ts
265
- Logger.error
266
- ```
267
-
268
- ***
269
-
270
- ### info
271
-
272
- ```ts
273
- info: LogFunction;
274
- ```
275
-
276
- ### Implementation of
277
-
278
- ```ts
279
- Logger.info
280
- ```
281
-
282
- ***
283
-
284
- ### log
285
-
286
- ```ts
287
- log: LogFunction;
288
- ```
289
-
290
- ### Implementation of
291
-
292
- ```ts
293
- Logger.log
294
- ```
295
-
296
- ***
297
-
298
- ### trace
299
-
300
- ```ts
301
- trace: LogFunction;
302
- ```
303
-
304
- ### Implementation of
305
-
306
- ```ts
307
- Logger.trace
308
- ```
309
-
310
- ***
311
-
312
- ### warn
313
-
314
- ```ts
315
- warn: LogFunction;
316
- ```
317
-
318
- ### Implementation of
319
-
320
- ```ts
321
- Logger.warn
322
- ```
323
-
324
- ### functions
325
-
326
- ### <a id="addRouteDefinitions"></a>addRouteDefinitions
327
-
328
- [**@xylabs/express**](#../README)
329
-
330
- ***
331
-
332
- ```ts
333
- function addRouteDefinitions(app, routeDefinitions): void;
334
- ```
335
-
336
- Registers an array of route definitions on an Express application.
337
-
338
- ## Parameters
339
-
340
- ### app
341
-
342
- `Express`
343
-
344
- The Express application to register routes on.
345
-
346
- ### routeDefinitions
347
-
348
- [`RouteDefinition`](#../interfaces/RouteDefinition)\<`RequestHandler`\<`ParamsDictionary`, `any`, `any`, `ParsedQs`, `Record`\<`string`, `any`\>\>\>[]
349
-
350
- The route definitions to register.
351
-
352
- ## Returns
353
-
354
- `void`
355
-
356
- ### <a id="asyncHandler"></a>asyncHandler
357
-
358
- [**@xylabs/express**](#../README)
359
-
360
- ***
361
-
362
- ```ts
363
- function asyncHandler<P, ResBody, ReqBody, ReqQuery, Locals>(fn): (req, res, next) => Promise<unknown>;
364
- ```
365
-
366
- Wraps an async Express request handler to forward rejected promises to the error handler.
367
-
368
- ## Type Parameters
369
-
370
- ### P
371
-
372
- `P` = `ParamsDictionary`
373
-
374
- ### ResBody
375
-
376
- `ResBody` = [`Empty`](#../interfaces/Empty)
377
-
378
- ### ReqBody
379
-
380
- `ReqBody` = [`Empty`](#../interfaces/Empty)
381
-
382
- ### ReqQuery
383
-
384
- `ReqQuery` = `ParsedQs`
385
-
386
- ### Locals
387
-
388
- `Locals` *extends* [`NoLocals`](#../type-aliases/NoLocals) = [`NoLocals`](#../type-aliases/NoLocals)
389
-
390
- ## Parameters
391
-
392
- ### fn
393
-
394
- `RequestHandler`\<`P`, `ResBody`, `ReqBody`, `ReqQuery`, `Locals`\>
395
-
396
- The async request handler to wrap.
397
-
398
- ## Returns
399
-
400
- A request handler that catches async errors and passes them to next().
401
-
402
- (`req`, `res`, `next`) => `Promise`\<`unknown`\>
403
-
404
- ### <a id="clearRawResponseFormat"></a>clearRawResponseFormat
405
-
406
- [**@xylabs/express**](#../README)
407
-
408
- ***
409
-
410
- ```ts
411
- function clearRawResponseFormat(res): void;
412
- ```
413
-
414
- Clears any flags on the response, allowing the response to
415
- use the default standard response envelope
416
-
417
- ## Parameters
418
-
419
- ### res
420
-
421
- `Response`
422
-
423
- The response to set to the standard response format
424
-
425
- ## Returns
426
-
427
- `void`
428
-
429
- ### <a id="compactObject"></a>compactObject
430
-
431
- [**@xylabs/express**](#../README)
432
-
433
- ***
434
-
435
- ```ts
436
- function compactObject<T>(obj): T;
437
- ```
438
-
439
- Returns a shallow copy of the object with all null and undefined values removed.
440
-
441
- ## Type Parameters
442
-
443
- ### T
444
-
445
- `T` *extends* `Record`\<`string`, `unknown`\>
446
-
447
- ## Parameters
448
-
449
- ### obj
450
-
451
- `T`
452
-
453
- The object to compact.
454
-
455
- ## Returns
456
-
457
- `T`
458
-
459
- A new object with only defined, non-null properties.
460
-
461
- ### <a id="customPoweredByHeader"></a>customPoweredByHeader
462
-
463
- [**@xylabs/express**](#../README)
464
-
465
- ***
466
-
467
- ```ts
468
- function customPoweredByHeader(
469
- req,
470
- res,
471
- next): void;
472
- ```
473
-
474
- Express middleware that sets the X-Powered-By header to 'XYO'.
475
-
476
- ## Parameters
477
-
478
- ### req
479
-
480
- `Request`
481
-
482
- ### res
483
-
484
- `Response`
485
-
486
- ### next
487
-
488
- `NextFunction`
489
-
490
- ## Returns
491
-
492
- `void`
493
-
494
- ### <a id="disableCaseSensitiveRouting"></a>disableCaseSensitiveRouting
495
-
496
- [**@xylabs/express**](#../README)
497
-
498
- ***
499
-
500
- ```ts
501
- function disableCaseSensitiveRouting(app): void;
502
- ```
503
-
504
- Disable case sensitivity. When enabled, "/Foo" and "/foo" are different
505
- routes. When disabled, "/Foo" and "/foo" are treated the same.
506
-
507
- ## Parameters
508
-
509
- ### app
510
-
511
- `Express`
512
-
513
- The Express app to disable the header on.
514
-
515
- ## Returns
516
-
517
- `void`
518
-
519
- ### <a id="disableExpressDefaultPoweredByHeader"></a>disableExpressDefaultPoweredByHeader
520
-
521
- [**@xylabs/express**](#../README)
522
-
523
- ***
524
-
525
- ```ts
526
- function disableExpressDefaultPoweredByHeader(app): void;
527
- ```
528
-
529
- By default Express appends the `X-Powered-By: Express` header to
530
- all responses. Calling this method disables that behavior.
531
-
532
- ## Parameters
533
-
534
- ### app
535
-
536
- `Express`
537
-
538
- The Express app to disable the header on.
539
-
540
- ## Returns
541
-
542
- `void`
543
-
544
- ### <a id="enableCaseSensitiveRouting"></a>enableCaseSensitiveRouting
545
-
546
- [**@xylabs/express**](#../README)
547
-
548
- ***
549
-
550
- ```ts
551
- function enableCaseSensitiveRouting(app): void;
552
- ```
553
-
554
- Enable case sensitivity. When enabled, "/Foo" and "/foo" are different
555
- routes. When disabled, "/Foo" and "/foo" are treated the same.
556
-
557
- ## Parameters
558
-
559
- ### app
560
-
561
- `Express`
562
-
563
- The Express app to disable the header on.
564
-
565
- ## Returns
566
-
567
- `void`
568
-
569
- ### <a id="enableExpressDefaultPoweredByHeader"></a>enableExpressDefaultPoweredByHeader
570
-
571
- [**@xylabs/express**](#../README)
572
-
573
- ***
574
-
575
- ```ts
576
- function enableExpressDefaultPoweredByHeader(app): void;
577
- ```
578
-
579
- By default Express appends the `X-Powered-By: Express` header to
580
- all responses. Calling this method enables that behavior.
581
-
582
- ## Parameters
583
-
584
- ### app
585
-
586
- `Express`
587
-
588
- The Express app to disable the header on.
589
-
590
- ## Returns
591
-
592
- `void`
593
-
594
- ### <a id="errorToJsonHandler"></a>errorToJsonHandler
595
-
596
- [**@xylabs/express**](#../README)
597
-
598
- ***
599
-
600
- ```ts
601
- function errorToJsonHandler(
602
- error,
603
- req,
604
- res,
605
- next): void;
606
- ```
607
-
608
- Express error handler that logs the error and sends a JSON response with the error message and status code.
609
-
610
- ## Parameters
611
-
612
- ### error
613
-
614
- [`ExpressError`](#../interfaces/ExpressError)
615
-
616
- The Express error to handle.
617
-
618
- ### req
619
-
620
- `Request`
621
-
622
- The incoming request.
623
-
624
- ### res
625
-
626
- `Response`
627
-
628
- The outgoing response.
629
-
630
- ### next
631
-
632
- `NextFunction`
633
-
634
- The next middleware function.
635
-
636
- ## Returns
637
-
638
- `void`
639
-
640
- ### <a id="getDefaultLogger"></a>getDefaultLogger
641
-
642
- [**@xylabs/express**](#../README)
643
-
644
- ***
645
-
646
- ```ts
647
- function getDefaultLogger(): Logger;
648
- ```
649
-
650
- Returns the singleton default logger instance, creating one if it does not exist.
651
-
652
- ## Returns
653
-
654
- `Logger`
655
-
656
- The default logger.
657
-
658
- ### <a id="getHttpHeader"></a>getHttpHeader
659
-
660
- [**@xylabs/express**](#../README)
661
-
662
- ***
663
-
664
- ```ts
665
- function getHttpHeader(header, req): string | undefined;
666
- ```
667
-
668
- Since there can be multiple of certain HTTP headers or
669
- to prevent ugliness if someone did send us multiple
670
- instances of a header we only expect one of, this
671
- method grabs the 1st/only one of the desired header
672
-
673
- ## Parameters
674
-
675
- ### header
676
-
677
- `string`
678
-
679
- The header to find
680
-
681
- ### req
682
-
683
- `Request`
684
-
685
- The received HTTP request (with headers)
686
-
687
- ## Returns
688
-
689
- `string` \| `undefined`
690
-
691
- The first or only occurrence of the specified HTTP header
692
-
693
- ### <a id="getJsonBodyParser"></a>getJsonBodyParser
694
-
695
- [**@xylabs/express**](#../README)
696
-
697
- ***
698
-
699
- ```ts
700
- function getJsonBodyParser(options?): NextHandleFunction;
701
- ```
702
-
703
- Get a JSON Body Parser connect middleware handler
704
-
705
- ## Parameters
706
-
707
- ### options?
708
-
709
- `OptionsJson` = `DefaultJsonBodyParserOptions`
710
-
711
- The options for the JSON Body Parser
712
-
713
- ## Returns
714
-
715
- `NextHandleFunction`
716
-
717
- A middleware function that parses JSON bodies
718
-
719
- ### <a id="getJsonBodyParserOptions"></a>getJsonBodyParserOptions
720
-
721
- [**@xylabs/express**](#../README)
722
-
723
- ***
724
-
725
- ```ts
726
- function getJsonBodyParserOptions(options?): OptionsJson;
727
- ```
728
-
729
- Gets the default JSON Body Parser options merged with the supplied options
730
- with the supplied options taking precedence
731
-
732
- ## Parameters
733
-
734
- ### options?
735
-
736
- `Partial`\<`OptionsJson`\>
737
-
738
- The options to override the default JSON Body Parser options with
739
-
740
- ## Returns
741
-
742
- `OptionsJson`
743
-
744
- The combined JSON Body Parser options with the supplied values taking
745
- precedence over the default
746
-
747
- ### <a id="getLogger"></a>getLogger
748
-
749
- [**@xylabs/express**](#../README)
750
-
751
- ***
752
-
753
- ```ts
754
- function getLogger(minVerbosity?): Logger;
755
- ```
756
-
757
- Returns a cached Winston-backed logger at the specified verbosity level.
758
-
759
- ## Parameters
760
-
761
- ### minVerbosity?
762
-
763
- [`LoggerVerbosity`](#../type-aliases/LoggerVerbosity) = `'info'`
764
-
765
- The minimum log level to output. Defaults to 'info'.
766
-
767
- ## Returns
768
-
769
- `Logger`
770
-
771
- A logger instance configured for the given verbosity.
772
-
773
- ### <a id="getResponseMetadata"></a>getResponseMetadata
774
-
775
- [**@xylabs/express**](#../README)
776
-
777
- ***
778
-
779
- ```ts
780
- function getResponseMetadata(res): Record<string, unknown>;
781
- ```
782
-
783
- Extracts response metadata from res.locals, computing profile duration if profiling was started.
784
-
785
- ## Parameters
786
-
787
- ### res
788
-
789
- `Response`
790
-
791
- The Express response to extract metadata from.
792
-
793
- ## Returns
794
-
795
- `Record`\<`string`, `unknown`\>
796
-
797
- The metadata record including any profiling information.
798
-
799
- ### <a id="isRawResponseFormatSet"></a>isRawResponseFormatSet
800
-
801
- [**@xylabs/express**](#../README)
802
-
803
- ***
804
-
805
- ```ts
806
- function isRawResponseFormatSet(res): boolean;
807
- ```
808
-
809
- Checks if there are any flags on the response that would cause it
810
- to forgo the standard response envelope and return the raw response
811
- body to the client
812
-
813
- ## Parameters
814
-
815
- ### res
816
-
817
- `Response`
818
-
819
- ## Returns
820
-
821
- `boolean`
822
-
823
- True if there are any flags on the response, false otherwise
824
-
825
- ### <a id="requestHandlerValidator"></a>requestHandlerValidator
826
-
827
- [**@xylabs/express**](#../README)
828
-
829
- ***
830
-
831
- ```ts
832
- function requestHandlerValidator<TParams, TQuery, TBody, TResponse>(schemas?): (handler) => RequestHandler;
833
- ```
834
-
835
- Factory for Express middleware that validates request and response objects using Zod schemas.
836
-
837
- ## Type Parameters
838
-
839
- ### TParams
840
-
841
- `TParams` *extends*
842
- \| `ZodObject`\<\{
843
- \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\>
844
- \| `ZodType`\<`Record`\<`string`, `string`\>, `unknown`, `$ZodTypeInternals`\<`Record`\<`string`, `string`\>, `unknown`\>\> = `ZodObject`\<\{
845
- \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\>
846
-
847
- ### TQuery
848
-
849
- `TQuery` *extends*
850
- \| `ZodObject`\<\{
851
- \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\>
852
- \| `ZodType`\<`Record`\<`string`, `string` \| `string`[]\>, `unknown`, `$ZodTypeInternals`\<`Record`\<`string`, `string` \| `string`[]\>, `unknown`\>\> = `ZodObject`\<\{
853
- \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\>
854
-
855
- ### TBody
856
-
857
- `TBody` *extends* `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> = `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\>
858
-
859
- ### TResponse
860
-
861
- `TResponse` *extends* `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> = `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\>
862
-
863
- ## Parameters
864
-
865
- ### schemas?
866
-
867
- `Partial`\<\{
868
- `body`: `TBody`;
869
- `params`: `TParams`;
870
- `query`: `TQuery`;
871
- `response`: `TResponse`;
872
- \}\>
873
-
874
- The Zod schemas to use for validation.
875
-
876
- ## Returns
877
-
878
- A middleware function for validating requests and responses.
879
-
880
- (`handler`) => `RequestHandler`
881
-
882
- ### <a id="responseProfiler"></a>responseProfiler
883
-
884
- [**@xylabs/express**](#../README)
885
-
886
- ***
887
-
888
- ```ts
889
- function responseProfiler(
890
- _req,
891
- res,
892
- next): void;
893
- ```
894
-
895
- Connect middleware to enable profiling of response lifecycle timing. To effectively profile
896
- the response timing, this middleware needs to be called first when initializing your Express
897
- App
898
-
899
- ## Parameters
900
-
901
- ### \_req
902
-
903
- `Request`
904
-
905
- The request
906
-
907
- ### res
908
-
909
- `Response`
910
-
911
- The response
912
-
913
- ### next
914
-
915
- `NextFunction`
916
-
917
- The next function
918
-
919
- ## Returns
920
-
921
- `void`
922
-
923
- ## Example
924
-
925
- ```ts
926
- const app = express()
927
- app.use(responseProfiler)
928
- // other initialization ...
929
- ```
930
-
931
- ### <a id="setRawResponseFormat"></a>setRawResponseFormat
932
-
933
- [**@xylabs/express**](#../README)
934
-
935
- ***
936
-
937
- ```ts
938
- function setRawResponseFormat(res): void;
939
- ```
940
-
941
- Flags the response to forgo the standard response envelope
942
- and return the raw response body to the client
943
-
944
- ## Parameters
945
-
946
- ### res
947
-
948
- `Response`
949
-
950
- The response to disable the standard response format on
951
-
952
- ## Returns
953
-
954
- `void`
955
-
956
- ### <a id="standardErrors"></a>standardErrors
957
-
958
- [**@xylabs/express**](#../README)
959
-
960
- ***
961
-
962
- ```ts
963
- function standardErrors(
964
- err,
965
- req,
966
- res,
967
- next): void;
968
- ```
969
-
970
- Express error handler that logs the error and sends a JSON:API-compliant error response.
971
-
972
- ## Parameters
973
-
974
- ### err
975
-
976
- [`ExpressError`](#../interfaces/ExpressError) \| `undefined`
977
-
978
- The error to handle, or undefined if no error.
979
-
980
- ### req
981
-
982
- `Request`
983
-
984
- The incoming request.
985
-
986
- ### res
987
-
988
- `Response`
989
-
990
- The outgoing response.
991
-
992
- ### next
993
-
994
- `NextFunction`
995
-
996
- The next middleware function.
997
-
998
- ## Returns
999
-
1000
- `void`
1001
-
1002
- ### <a id="tryParse"></a>tryParse
1003
-
1004
- [**@xylabs/express**](#../README)
1005
-
1006
- ***
1007
-
1008
- ```ts
1009
- function tryParse<T>(func, value?): T & object | undefined;
1010
- ```
1011
-
1012
- ## Type Parameters
1013
-
1014
- ### T
1015
-
1016
- `T` = `number`
1017
-
1018
- ## Parameters
1019
-
1020
- ### func
1021
-
1022
- [`ParseFunc`](#../type-aliases/ParseFunc)\<`T`\>
1023
-
1024
- ### value?
1025
-
1026
- `string`
1027
-
1028
- ## Returns
1029
-
1030
- `T` & `object` \| `undefined`
1031
-
1032
- ## Deprecated
1033
-
1034
- use zod instead
1035
-
1036
- ### <a id="useRequestCounters"></a>useRequestCounters
1037
-
1038
- [**@xylabs/express**](#../README)
1039
-
1040
- ***
1041
-
1042
- ```ts
1043
- function useRequestCounters(app): void;
1044
- ```
1045
-
1046
- Registers middleware that increments per-path request counters and exposes a /stats endpoint.
1047
-
1048
- ## Parameters
1049
-
1050
- ### app
1051
-
1052
- `Application`
1053
-
1054
- The Express application to attach counters to.
1055
-
1056
- ## Returns
1057
-
1058
- `void`
1059
-
1060
- ### interfaces
1061
-
1062
- ### <a id="ApiDataResponse"></a>ApiDataResponse
1063
-
1064
- [**@xylabs/express**](#../README)
1065
-
1066
- ***
1067
-
1068
- A successful JSON:API response containing primary data and optional included resources.
1069
-
1070
- ## Extends
1071
-
1072
- - [`ApiResponseBase`](#ApiResponseBase)
1073
-
1074
- ## Type Parameters
1075
-
1076
- ### T
1077
-
1078
- `T` *extends* [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject)
1079
-
1080
- ## Properties
1081
-
1082
- ### jsonapi?
1083
-
1084
- ```ts
1085
- optional jsonapi?: JsonApi;
1086
- ```
1087
-
1088
- ### Inherited from
1089
-
1090
- [`ApiResponseBase`](#ApiResponseBase).[`jsonapi`](ApiResponseBase.md#jsonapi)
1091
-
1092
- ***
1093
-
1094
- ### links?
1095
-
1096
- ```ts
1097
- optional links?: ApiLinks;
1098
- ```
1099
-
1100
- ### Inherited from
1101
-
1102
- [`ApiResponseBase`](#ApiResponseBase).[`links`](ApiResponseBase.md#links)
1103
-
1104
- ***
1105
-
1106
- ### meta?
1107
-
1108
- ```ts
1109
- optional meta?: Record<string, unknown>;
1110
- ```
1111
-
1112
- ### Inherited from
1113
-
1114
- [`ApiResponseBase`](#ApiResponseBase).[`meta`](ApiResponseBase.md#meta)
1115
-
1116
- ***
1117
-
1118
- ### data
1119
-
1120
- ```ts
1121
- data: T;
1122
- ```
1123
-
1124
- ***
1125
-
1126
- ### included?
1127
-
1128
- ```ts
1129
- optional included?: ApiResourceObject[];
1130
- ```
1131
-
1132
- ### <a id="ApiError"></a>ApiError
1133
-
1134
- [**@xylabs/express**](#../README)
1135
-
1136
- ***
1137
-
1138
- ## Properties
1139
-
1140
- ### code?
1141
-
1142
- ```ts
1143
- optional code?: string;
1144
- ```
1145
-
1146
- An application-specific error code, expressed as a string value.
1147
-
1148
- ***
1149
-
1150
- ### detail?
1151
-
1152
- ```ts
1153
- optional detail?: string;
1154
- ```
1155
-
1156
- A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized.
1157
-
1158
- ***
1159
-
1160
- ### id?
1161
-
1162
- ```ts
1163
- optional id?: string;
1164
- ```
1165
-
1166
- A unique identifier for this particular occurrence of the problem.
1167
-
1168
- ***
1169
-
1170
- ### links?
1171
-
1172
- ```ts
1173
- optional links?: ApiLinks;
1174
- ```
1175
-
1176
- A links object containing the following members:
1177
- about: a link that leads to further details about this particular occurrence of the problem
1178
-
1179
- ***
1180
-
1181
- ### meta?
1182
-
1183
- ```ts
1184
- optional meta?: Record<string, unknown>;
1185
- ```
1186
-
1187
- A meta object containing non-standard meta-information about the error.
1188
-
1189
- ***
1190
-
1191
- ### source?
1192
-
1193
- ```ts
1194
- optional source?: Source;
1195
- ```
1196
-
1197
- An object containing references to the source of the error, optionally including any of the following members:
1198
-
1199
- ***
1200
-
1201
- ### status?
1202
-
1203
- ```ts
1204
- optional status?: string;
1205
- ```
1206
-
1207
- The HTTP status code applicable to this problem, expressed as a string value.
1208
-
1209
- ***
1210
-
1211
- ### title?
1212
-
1213
- ```ts
1214
- optional title?: string;
1215
- ```
1216
-
1217
- A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.
1218
-
1219
- ### <a id="ApiErrorResponse"></a>ApiErrorResponse
1220
-
1221
- [**@xylabs/express**](#../README)
1222
-
1223
- ***
1224
-
1225
- A JSON:API error response containing one or more error objects.
1226
-
1227
- ## Extends
1228
-
1229
- - [`ApiResponseBase`](#ApiResponseBase)
1230
-
1231
- ## Properties
1232
-
1233
- ### jsonapi?
1234
-
1235
- ```ts
1236
- optional jsonapi?: JsonApi;
1237
- ```
1238
-
1239
- ### Inherited from
1240
-
1241
- [`ApiResponseBase`](#ApiResponseBase).[`jsonapi`](ApiResponseBase.md#jsonapi)
1242
-
1243
- ***
1244
-
1245
- ### links?
1246
-
1247
- ```ts
1248
- optional links?: ApiLinks;
1249
- ```
1250
-
1251
- ### Inherited from
1252
-
1253
- [`ApiResponseBase`](#ApiResponseBase).[`links`](ApiResponseBase.md#links)
1254
-
1255
- ***
1256
-
1257
- ### meta?
1258
-
1259
- ```ts
1260
- optional meta?: Record<string, unknown>;
1261
- ```
1262
-
1263
- ### Inherited from
1264
-
1265
- [`ApiResponseBase`](#ApiResponseBase).[`meta`](ApiResponseBase.md#meta)
1266
-
1267
- ***
1268
-
1269
- ### errors
1270
-
1271
- ```ts
1272
- errors: ApiError[];
1273
- ```
1274
-
1275
- ### <a id="ApiResourceIdentifierObject"></a>ApiResourceIdentifierObject
1276
-
1277
- [**@xylabs/express**](#../README)
1278
-
1279
- ***
1280
-
1281
- Within a given API, each resource object's type and id pair MUST identify a single, unique resource.
1282
- (The set of URIs controlled by a server, or multiple servers acting as one, constitute an API.)
1283
-
1284
- ## Extended by
1285
-
1286
- - [`ApiResourceObject`](#ApiResourceObject)
1287
-
1288
- ## Properties
1289
-
1290
- ### id
1291
-
1292
- ```ts
1293
- id: string;
1294
- ```
1295
-
1296
- The id member is not required when the resource object originates at the client and represents a new resource to be created on the server.
1297
-
1298
- ***
1299
-
1300
- ### type
1301
-
1302
- ```ts
1303
- type: string;
1304
- ```
1305
-
1306
- The type member is used to describe resource objects that share common attributes and relationships.
1307
- The values of type members MUST adhere to the same constraints as member names.
1308
-
1309
- ### <a id="ApiResourceObject"></a>ApiResourceObject
1310
-
1311
- [**@xylabs/express**](#../README)
1312
-
1313
- ***
1314
-
1315
- A JSON:API resource object with optional attributes, links, meta, and relationships.
1316
-
1317
- ## Extends
1318
-
1319
- - [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject)
1320
-
1321
- ## Properties
1322
-
1323
- ### id
1324
-
1325
- ```ts
1326
- id: string;
1327
- ```
1328
-
1329
- The id member is not required when the resource object originates at the client and represents a new resource to be created on the server.
1330
-
1331
- ### Inherited from
1332
-
1333
- [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject).[`id`](ApiResourceIdentifierObject.md#id)
1334
-
1335
- ***
1336
-
1337
- ### type
1338
-
1339
- ```ts
1340
- type: string;
1341
- ```
1342
-
1343
- The type member is used to describe resource objects that share common attributes and relationships.
1344
- The values of type members MUST adhere to the same constraints as member names.
1345
-
1346
- ### Inherited from
1347
-
1348
- [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject).[`type`](ApiResourceIdentifierObject.md#type)
1349
-
1350
- ***
1351
-
1352
- ### attributes?
1353
-
1354
- ```ts
1355
- optional attributes?: Record<string, unknown>;
1356
- ```
1357
-
1358
- An attributes object representing some of the resource's data.
1359
-
1360
- ***
1361
-
1362
- ### links?
1363
-
1364
- ```ts
1365
- optional links?: ApiLinks;
1366
- ```
1367
-
1368
- A links object containing links related to the resource.
1369
-
1370
- ***
1371
-
1372
- ### meta?
1373
-
1374
- ```ts
1375
- optional meta?: Record<string, unknown>;
1376
- ```
1377
-
1378
- A meta object containing non-standard meta-information about a resource that can not be represented as an attribute or relationship.
1379
-
1380
- ***
1381
-
1382
- ### relationships?
1383
-
1384
- ```ts
1385
- optional relationships?: Record<string, Relationship>;
1386
- ```
1387
-
1388
- A relationships object describing relationships between the resource and other JSON:API resources.
1389
-
1390
- ### <a id="ApiResponseBase"></a>ApiResponseBase
1391
-
1392
- [**@xylabs/express**](#../README)
1393
-
1394
- ***
1395
-
1396
- Base interface for all JSON:API responses, including optional links and metadata.
1397
-
1398
- ## Extended by
1399
-
1400
- - [`ApiDataResponse`](#ApiDataResponse)
1401
- - [`ApiErrorResponse`](#ApiErrorResponse)
1402
-
1403
- ## Properties
1404
-
1405
- ### jsonapi?
1406
-
1407
- ```ts
1408
- optional jsonapi?: JsonApi;
1409
- ```
1410
-
1411
- ***
1412
-
1413
- ### links?
1414
-
1415
- ```ts
1416
- optional links?: ApiLinks;
1417
- ```
1418
-
1419
- ***
1420
-
1421
- ### meta?
1422
-
1423
- ```ts
1424
- optional meta?: Record<string, unknown>;
1425
- ```
1426
-
1427
- ### <a id="Empty"></a>Empty
1428
-
1429
- [**@xylabs/express**](#../README)
1430
-
1431
- ***
1432
-
1433
- Empty object type used as a default for request/response body generics.
1434
-
1435
- ### <a id="ExpressError"></a>ExpressError
1436
-
1437
- [**@xylabs/express**](#../README)
1438
-
1439
- ***
1440
-
1441
- An Error with an optional HTTP status code for Express error handling.
1442
-
1443
- ## Extends
1444
-
1445
- - `Error`
1446
-
1447
- ## Properties
1448
-
1449
- ### statusCode?
1450
-
1451
- ```ts
1452
- optional statusCode?: number;
1453
- ```
1454
-
1455
- ### <a id="HrefWithMeta"></a>HrefWithMeta
1456
-
1457
- [**@xylabs/express**](#../README)
1458
-
1459
- ***
1460
-
1461
- A link with an href and associated metadata.
1462
-
1463
- ## Properties
1464
-
1465
- ### href
1466
-
1467
- ```ts
1468
- href: string;
1469
- ```
1470
-
1471
- ***
1472
-
1473
- ### meta
1474
-
1475
- ```ts
1476
- meta: Record<string, unknown>;
1477
- ```
1478
-
1479
- ### <a id="IRelationshipData"></a>IRelationshipData
1480
-
1481
- [**@xylabs/express**](#../README)
1482
-
1483
- ***
1484
-
1485
- Contains the resource linkage data for a JSON:API relationship.
1486
-
1487
- ## Properties
1488
-
1489
- ### data
1490
-
1491
- ```ts
1492
- data: ResourceLinkage;
1493
- ```
1494
-
1495
- ### <a id="IRelationshipLinks"></a>IRelationshipLinks
1496
-
1497
- [**@xylabs/express**](#../README)
1498
-
1499
- ***
1500
-
1501
- Contains the links for a JSON:API relationship.
1502
-
1503
- ## Properties
1504
-
1505
- ### links
1506
-
1507
- ```ts
1508
- links:
1509
- | IRelationshipSelfLink
1510
- | IRelationshipRelatedLink;
1511
- ```
1512
-
1513
- ### <a id="IRelationshipRelatedLink"></a>IRelationshipRelatedLink
1514
-
1515
- [**@xylabs/express**](#../README)
1516
-
1517
- ***
1518
-
1519
- A relationship link pointing to a related resource.
1520
-
1521
- ## Properties
1522
-
1523
- ### related
1524
-
1525
- ```ts
1526
- related: string;
1527
- ```
1528
-
1529
- A related resource link
1530
-
1531
- ### <a id="IRelationshipSelfLink"></a>IRelationshipSelfLink
1532
-
1533
- [**@xylabs/express**](#../README)
1534
-
1535
- ***
1536
-
1537
- A relationship link pointing to the relationship itself.
1538
-
1539
- ## Properties
1540
-
1541
- ### self
1542
-
1543
- ```ts
1544
- self: string;
1545
- ```
1546
-
1547
- A link for the relationship itself (a "relationship link"). This link allows the client to directly manipulate the relationship.
1548
- For example, removing an author through an article’s relationship URL would disconnect the person from the article without
1549
- deleting the people resource itself. When fetched successfully, this link returns the linkage for the related resources as its primary data.
1550
-
1551
- ### <a id="JsonApi"></a>JsonApi
1552
-
1553
- [**@xylabs/express**](#../README)
1554
-
1555
- ***
1556
-
1557
- JSON:API version and metadata descriptor.
1558
-
1559
- ## Properties
1560
-
1561
- ### meta?
1562
-
1563
- ```ts
1564
- optional meta?: Record<string, unknown>;
1565
- ```
1566
-
1567
- ***
1568
-
1569
- ### version?
1570
-
1571
- ```ts
1572
- optional version?: "1.0" | "1.1";
1573
- ```
1574
-
1575
- ### <a id="LoggerOptions"></a>LoggerOptions
1576
-
1577
- [**@xylabs/express**](#../README)
1578
-
1579
- ***
1580
-
1581
- Configuration options for creating a logger instance.
1582
-
1583
- ## Properties
1584
-
1585
- ### defaultMeta?
1586
-
1587
- ```ts
1588
- optional defaultMeta?: LoggerMeta;
1589
- ```
1590
-
1591
- ***
1592
-
1593
- ### level?
1594
-
1595
- ```ts
1596
- optional level?: LoggerVerbosity;
1597
- ```
1598
-
1599
- ### <a id="RouteDefinition"></a>RouteDefinition
1600
-
1601
- [**@xylabs/express**](#../README)
1602
-
1603
- ***
1604
-
1605
- Defines an Express route with its HTTP method, path, and handler(s).
1606
-
1607
- ## Type Parameters
1608
-
1609
- ### H
1610
-
1611
- `H` *extends* `RequestHandler` = `RequestHandler`
1612
-
1613
- ## Properties
1614
-
1615
- ### handlers
1616
-
1617
- ```ts
1618
- handlers: H | H[];
1619
- ```
1620
-
1621
- ***
1622
-
1623
- ### method
1624
-
1625
- ```ts
1626
- method: HttpMethod;
1627
- ```
1628
-
1629
- ***
1630
-
1631
- ### path
1632
-
1633
- ```ts
1634
- path: string | RegExp;
1635
- ```
1636
-
1637
- ### <a id="Source"></a>Source
1638
-
1639
- [**@xylabs/express**](#../README)
1640
-
1641
- ***
1642
-
1643
- An object containing references to the source of the error
1644
-
1645
- ## Properties
1646
-
1647
- ### parameter?
1648
-
1649
- ```ts
1650
- optional parameter?: string;
1651
- ```
1652
-
1653
- A string indicating which URI query parameter caused the error.
1654
-
1655
- ***
1656
-
1657
- ### pointer?
1658
-
1659
- ```ts
1660
- optional pointer?: string;
1661
- ```
1662
-
1663
- A JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object,
1664
- or "/data/attributes/title" for a specific attribute].
1665
-
1666
- ### type-aliases
1667
-
1668
- ### <a id="ApiLink"></a>ApiLink
1669
-
1670
- [**@xylabs/express**](#../README)
1671
-
1672
- ***
1673
-
1674
- ```ts
1675
- type ApiLink = string | HrefWithMeta;
1676
- ```
1677
-
1678
- A JSON:API link, either a simple URL string or an object with href and metadata.
1679
-
1680
- ### <a id="ApiLinks"></a>ApiLinks
1681
-
1682
- [**@xylabs/express**](#../README)
1683
-
1684
- ***
1685
-
1686
- ```ts
1687
- type ApiLinks = Record<string, ApiLink>;
1688
- ```
1689
-
1690
- A collection of named JSON:API links.
1691
-
1692
- ### <a id="ApiResponse"></a>ApiResponse
1693
-
1694
- [**@xylabs/express**](#../README)
1695
-
1696
- ***
1697
-
1698
- ```ts
1699
- type ApiResponse<T> =
1700
- | ApiDataResponse<T>
1701
- | ApiErrorResponse;
1702
- ```
1703
-
1704
- A JSON:API response, either a data response or an error response.
1705
-
1706
- ## Type Parameters
1707
-
1708
- ### T
1709
-
1710
- `T` *extends* [`ApiResourceIdentifierObject`](#../interfaces/ApiResourceIdentifierObject)
1711
-
1712
- ### <a id="HttpMethod"></a>HttpMethod
1713
-
1714
- [**@xylabs/express**](#../README)
1715
-
1716
- ***
1717
-
1718
- ```ts
1719
- type HttpMethod = "get" | "post" | "put" | "patch" | "delete" | "options" | "head";
1720
- ```
1721
-
1722
- Supported HTTP methods for route definitions.
1723
-
1724
- ### <a id="LogFunction"></a>LogFunction
1725
-
1726
- [**@xylabs/express**](#../README)
1727
-
1728
- ***
1729
-
1730
- ```ts
1731
- type LogFunction = XyLabsLogFunction;
1732
- ```
1733
-
1734
- ## Deprecated
1735
-
1736
- use from @xylabs/logger instead
1737
-
1738
- ### <a id="Logger"></a>Logger
1739
-
1740
- [**@xylabs/express**](#../README)
1741
-
1742
- ***
1743
-
1744
- ```ts
1745
- type Logger = XyLabsLogger;
1746
- ```
1747
-
1748
- ## Deprecated
1749
-
1750
- use from @xylabs/logger instead
1751
-
1752
- ### <a id="LoggerMeta"></a>LoggerMeta
1753
-
1754
- [**@xylabs/express**](#../README)
1755
-
1756
- ***
1757
-
1758
- ```ts
1759
- type LoggerMeta = Record<string, string | number>;
1760
- ```
1761
-
1762
- Metadata key-value pairs attached to log entries.
1763
-
1764
- ### <a id="LoggerVerbosity"></a>LoggerVerbosity
1765
-
1766
- [**@xylabs/express**](#../README)
1767
-
1768
- ***
1769
-
1770
- ```ts
1771
- type LoggerVerbosity = "error" | "warn" | "info" | "debug" | "all";
1772
- ```
1773
-
1774
- Application-level log verbosity levels.
1775
-
1776
- ### <a id="NoLocals"></a>NoLocals
1777
-
1778
- [**@xylabs/express**](#../README)
1779
-
1780
- ***
1781
-
1782
- ```ts
1783
- type NoLocals = Record<string, any>;
1784
- ```
1785
-
1786
- Default type for response locals.
1787
-
1788
- ### <a id="NoReqBody"></a>NoReqBody
1789
-
1790
- [**@xylabs/express**](#../README)
1791
-
1792
- ***
1793
-
1794
- ```ts
1795
- type NoReqBody = Empty;
1796
- ```
1797
-
1798
- Default type for request body when none is specified.
1799
-
1800
- ### <a id="NoReqParams"></a>NoReqParams
1801
-
1802
- [**@xylabs/express**](#../README)
1803
-
1804
- ***
1805
-
1806
- ```ts
1807
- type NoReqParams = ParamsDictionary;
1808
- ```
1809
-
1810
- Default type for request route parameters.
1811
-
1812
- ### <a id="NoReqQuery"></a>NoReqQuery
1813
-
1814
- [**@xylabs/express**](#../README)
1815
-
1816
- ***
1817
-
1818
- ```ts
1819
- type NoReqQuery = Query;
1820
- ```
1821
-
1822
- Default type for request query parameters.
1823
-
1824
- ### <a id="NoResBody"></a>NoResBody
1825
-
1826
- [**@xylabs/express**](#../README)
1827
-
1828
- ***
1829
-
1830
- ```ts
1831
- type NoResBody = Empty;
1832
- ```
1833
-
1834
- Default type for response body when none is specified.
1835
-
1836
- ### <a id="ParseFunc"></a>ParseFunc
1837
-
1838
- [**@xylabs/express**](#../README)
1839
-
1840
- ***
1841
-
1842
- ```ts
1843
- type ParseFunc<T> = (value) => T;
1844
- ```
1845
-
1846
- A function that parses a string value into the target type.
1847
-
1848
- ## Type Parameters
1849
-
1850
- ### T
1851
-
1852
- `T` = `number`
1853
-
1854
- ## Parameters
1855
-
1856
- ### value
1857
-
1858
- `string`
1859
-
1860
- ## Returns
1861
-
1862
- `T`
1863
-
1864
- ### <a id="Relationship"></a>Relationship
1865
-
1866
- [**@xylabs/express**](#../README)
1867
-
1868
- ***
1869
-
1870
- ```ts
1871
- type Relationship =
1872
- | IRelationshipLinks
1873
- | IRelationshipData
1874
- | RelationshipMeta;
1875
- ```
1876
-
1877
- The value of the relationships key MUST be an object (a "relationships object"). Members of the relationships object ("relationships")
1878
- represent references from the resource object in which it’s defined to other resource objects.
1879
- Relationships may be to-one or to-many.
1880
-
1881
- ### <a id="RelationshipMeta"></a>RelationshipMeta
1882
-
1883
- [**@xylabs/express**](#../README)
1884
-
1885
- ***
1886
-
1887
- ```ts
1888
- type RelationshipMeta = Record<string, unknown>;
1889
- ```
1890
-
1891
- Non-standard metadata associated with a JSON:API relationship.
1892
-
1893
- ### <a id="ResourceLinkage"></a>ResourceLinkage
1894
-
1895
- [**@xylabs/express**](#../README)
1896
-
1897
- ***
1898
-
1899
- ```ts
1900
- type ResourceLinkage =
1901
- | null
1902
- | []
1903
- | ApiResourceIdentifierObject
1904
- | ApiResourceIdentifierObject[];
1905
- ```
1906
-
1907
- Resource linkage in a compound document allows a client to link together all of the included resource objects without having to GET any URLs via links.
1908
- Resource linkage MUST be represented as one of the following:
1909
- • null for empty to-one relationships.
1910
- • an empty array ([]) for empty to-many relationships.
1911
- • a single resource identifier object for non-empty to-one relationships.
1912
- • an array of resource identifier objects for non-empty to-many relationships.
1913
-
1914
- ### variables
1915
-
1916
- ### <a id="DefaultJsonBodyParserOptions"></a>DefaultJsonBodyParserOptions
1917
-
1918
- [**@xylabs/express**](#../README)
1919
-
1920
- ***
1921
-
1922
- ```ts
1923
- const DefaultJsonBodyParserOptions: OptionsJson;
1924
- ```
1925
-
1926
- The default options for the JSON Body Parser
1927
-
1928
- ### <a id="DefaultJsonBodyParserOptionsLimit"></a>DefaultJsonBodyParserOptionsLimit
1929
-
1930
- [**@xylabs/express**](#../README)
1931
-
1932
- ***
1933
-
1934
- ```ts
1935
- const DefaultJsonBodyParserOptionsLimit: "100kb" = '100kb';
1936
- ```
1937
-
1938
- The default maximum request body size for the JSON Body Parser
1939
-
1940
- ### <a id="DefaultJsonBodyParserOptionsTypes"></a>DefaultJsonBodyParserOptionsTypes
1941
-
1942
- [**@xylabs/express**](#../README)
1943
-
1944
- ***
1945
-
1946
- ```ts
1947
- const DefaultJsonBodyParserOptionsTypes: string[];
1948
- ```
1949
-
1950
- The default MIME types for the JSON Body Parser
1951
-
1952
- ### <a id="EmptyParamsZod"></a>EmptyParamsZod
1953
-
1954
- [**@xylabs/express**](#../README)
1955
-
1956
- ***
1957
-
1958
- ```ts
1959
- const EmptyParamsZod: ZodObject<{
1960
- }, $catchall<ZodString>>;
1961
- ```
1962
-
1963
- Empty Zod schema for requests with no parameters.
1964
-
1965
- ### <a id="EmptyQueryParamsZod"></a>EmptyQueryParamsZod
1966
-
1967
- [**@xylabs/express**](#../README)
1968
-
1969
- ***
1970
-
1971
- ```ts
1972
- const EmptyQueryParamsZod: ZodObject<{
1973
- }, $catchall<ZodUnion<readonly [ZodString, ZodArray<ZodString>]>>>;
1974
- ```
1975
-
1976
- Empty Zod schema for requests with no query parameters.
1977
-
1978
- ### <a id="ValidateRequestDefaults"></a>ValidateRequestDefaults
1979
-
1980
- [**@xylabs/express**](#../README)
1981
-
1982
- ***
1983
-
1984
- ```ts
1985
- const ValidateRequestDefaults: object;
1986
- ```
1987
-
1988
- Default validation schemas for request handler validator.
1989
-
1990
- ## Type Declaration
1991
-
1992
- ### params
1993
-
1994
- ```ts
1995
- params: ZodObject<{
1996
- }, $catchall<ZodString>> = EmptyParamsZod;
1997
- ```
1998
-
1999
- ### query
2000
-
2001
- ```ts
2002
- query: ZodObject<{
2003
- }, $catchall<ZodUnion<readonly [ZodString, ZodArray<ZodString>]>>> = EmptyQueryParamsZod;
2004
- ```
2005
-
2006
- ### body
2007
-
2008
- ```ts
2009
- body: ZodOptional<ZodJSONSchema>;
2010
- ```
2011
-
2012
- ### response
2013
-
2014
- ```ts
2015
- response: ZodOptional<ZodJSONSchema>;
2016
- ```
2017
-
2018
- ### <a id="jsonBodyParser"></a>jsonBodyParser
2019
-
2020
- [**@xylabs/express**](#../README)
2021
-
2022
- ***
2023
-
2024
- ```ts
2025
- const jsonBodyParser: NextHandleFunction;
2026
- ```
2027
-
2028
- A JSON Body Parser middleware handler initialized with the default options
2029
-
2030
- ### <a id="notImplemented"></a>notImplemented
2031
-
2032
- [**@xylabs/express**](#../README)
2033
-
2034
- ***
2035
-
2036
- ```ts
2037
- const notImplemented: RequestHandler;
2038
- ```
2039
-
2040
- Express request handler that responds with a 501 Not Implemented error.
2041
-
2042
- ### <a id="standardResponses"></a>standardResponses
2043
-
2044
- [**@xylabs/express**](#../README)
2045
-
2046
- ***
2047
-
2048
- ```ts
2049
- const standardResponses: RequestHandler;
2050
- ```
2051
-
2052
- Connect middleware to enable the transform of all responses to match
2053
- the standard response format (compatible with JSON API)
2054
-
2055
- ## Credits
2056
-
2057
- [Made with 🔥 and ❄️ by XY Labs](https://xylabs.com)
2058
-
2059
- [npm-badge]: https://img.shields.io/npm/v/@xylabs/express.svg
2060
- [npm-link]: https://www.npmjs.com/package/@xylabs/express
2061
- [license-badge]: https://img.shields.io/npm/l/@xylabs/express.svg
2062
- [license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
2063
- [logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg
3
+ DEPRECATED — use `@ariestools/express` instead.