@xylabs/express 5.0.84 → 5.0.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +382 -913
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
SDK for base code for Api repos that use express and deploy on AWS ECS
|
|
17
17
|
|
|
18
|
+
|
|
19
|
+
|
|
18
20
|
## Reference
|
|
19
21
|
|
|
20
22
|
**@xylabs/express**
|
|
@@ -23,87 +25,97 @@ SDK for base code for Api repos that use express and deploy on AWS ECS
|
|
|
23
25
|
|
|
24
26
|
## Classes
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
| Class | Description |
|
|
29
|
+
| ------ | ------ |
|
|
30
|
+
| [WrappedWinstonLogger](#classes/WrappedWinstonLogger) | Wrap Winston logger methods to adapt to familiar console logging methods |
|
|
31
|
+
| [Counters](#classes/Counters) | Static counter registry for tracking named numeric metrics. |
|
|
32
|
+
| [Profiler](#classes/Profiler) | Measures and records the execution duration of async operations by name. |
|
|
29
33
|
|
|
30
34
|
## Interfaces
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
| Interface | Description |
|
|
37
|
+
| ------ | ------ |
|
|
38
|
+
| [RouteDefinition](#interfaces/RouteDefinition) | Defines an Express route with its HTTP method, path, and handler(s). |
|
|
39
|
+
| [Empty](#interfaces/Empty) | Empty object type used as a default for request/response body generics. |
|
|
40
|
+
| [LoggerOptions](#interfaces/LoggerOptions) | Configuration options for creating a logger instance. |
|
|
41
|
+
| [ExpressError](#interfaces/ExpressError) | An Error with an optional HTTP status code for Express error handling. |
|
|
42
|
+
| [Source](#interfaces/Source) | An object containing references to the source of the error |
|
|
43
|
+
| [ApiError](#interfaces/ApiError) | - |
|
|
44
|
+
| [HrefWithMeta](#interfaces/HrefWithMeta) | A link with an href and associated metadata. |
|
|
45
|
+
| [IRelationshipSelfLink](#interfaces/IRelationshipSelfLink) | A relationship link pointing to the relationship itself. |
|
|
46
|
+
| [IRelationshipRelatedLink](#interfaces/IRelationshipRelatedLink) | A relationship link pointing to a related resource. |
|
|
47
|
+
| [IRelationshipLinks](#interfaces/IRelationshipLinks) | Contains the links for a JSON:API relationship. |
|
|
48
|
+
| [IRelationshipData](#interfaces/IRelationshipData) | Contains the resource linkage data for a JSON:API relationship. |
|
|
49
|
+
| [ApiResourceIdentifierObject](#interfaces/ApiResourceIdentifierObject) | Within a given API, each resource object's type and id pair MUST identify a single, unique resource. (The set of URIs controlled by a server, or multiple servers acting as one, constitute an API.) |
|
|
50
|
+
| [ApiResourceObject](#interfaces/ApiResourceObject) | A JSON:API resource object with optional attributes, links, meta, and relationships. |
|
|
51
|
+
| [JsonApi](#interfaces/JsonApi) | JSON:API version and metadata descriptor. |
|
|
52
|
+
| [ApiResponseBase](#interfaces/ApiResponseBase) | Base interface for all JSON:API responses, including optional links and metadata. |
|
|
53
|
+
| [ApiDataResponse](#interfaces/ApiDataResponse) | A successful JSON:API response containing primary data and optional included resources. |
|
|
54
|
+
| [ApiErrorResponse](#interfaces/ApiErrorResponse) | A JSON:API error response containing one or more error objects. |
|
|
49
55
|
|
|
50
56
|
## Type Aliases
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
| Type Alias | Description |
|
|
59
|
+
| ------ | ------ |
|
|
60
|
+
| [HttpMethod](#type-aliases/HttpMethod) | Supported HTTP methods for route definitions. |
|
|
61
|
+
| [NoReqParams](#type-aliases/NoReqParams) | Default type for request route parameters. |
|
|
62
|
+
| [NoResBody](#type-aliases/NoResBody) | Default type for response body when none is specified. |
|
|
63
|
+
| [NoReqBody](#type-aliases/NoReqBody) | Default type for request body when none is specified. |
|
|
64
|
+
| [NoReqQuery](#type-aliases/NoReqQuery) | Default type for request query parameters. |
|
|
65
|
+
| [NoLocals](#type-aliases/NoLocals) | Default type for response locals. |
|
|
66
|
+
| [LoggerMeta](#type-aliases/LoggerMeta) | Metadata key-value pairs attached to log entries. |
|
|
67
|
+
| [LoggerVerbosity](#type-aliases/LoggerVerbosity) | Application-level log verbosity levels. |
|
|
68
|
+
| [~~LogFunction~~](#type-aliases/LogFunction) | - |
|
|
69
|
+
| [~~Logger~~](#type-aliases/Logger) | - |
|
|
70
|
+
| [ParseFunc](#type-aliases/ParseFunc) | A function that parses a string value into the target type. |
|
|
71
|
+
| [ApiLink](#type-aliases/ApiLink) | A JSON:API link, either a simple URL string or an object with href and metadata. |
|
|
72
|
+
| [ApiLinks](#type-aliases/ApiLinks) | A collection of named JSON:API links. |
|
|
73
|
+
| [ResourceLinkage](#type-aliases/ResourceLinkage) | 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. Resource linkage MUST be represented as one of the following: • null for empty to-one relationships. • an empty array ([]) for empty to-many relationships. • a single resource identifier object for non-empty to-one relationships. • an array of resource identifier objects for non-empty to-many relationships. |
|
|
74
|
+
| [RelationshipMeta](#type-aliases/RelationshipMeta) | Non-standard metadata associated with a JSON:API relationship. |
|
|
75
|
+
| [Relationship](#type-aliases/Relationship) | The value of the relationships key MUST be an object (a "relationships object"). Members of the relationships object ("relationships") represent references from the resource object in which it’s defined to other resource objects. Relationships may be to-one or to-many. |
|
|
76
|
+
| [ApiResponse](#type-aliases/ApiResponse) | A JSON:API response, either a data response or an error response. |
|
|
69
77
|
|
|
70
78
|
## Variables
|
|
71
79
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
| Variable | Description |
|
|
81
|
+
| ------ | ------ |
|
|
82
|
+
| [notImplemented](#variables/notImplemented) | Express request handler that responds with a 501 Not Implemented error. |
|
|
83
|
+
| [EmptyParamsZod](#variables/EmptyParamsZod) | Empty Zod schema for requests with no parameters. |
|
|
84
|
+
| [EmptyQueryParamsZod](#variables/EmptyQueryParamsZod) | Empty Zod schema for requests with no query parameters. |
|
|
85
|
+
| [ValidateRequestDefaults](#variables/ValidateRequestDefaults) | Default validation schemas for request handler validator. |
|
|
86
|
+
| [DefaultJsonBodyParserOptionsLimit](#variables/DefaultJsonBodyParserOptionsLimit) | The default maximum request body size for the JSON Body Parser |
|
|
87
|
+
| [DefaultJsonBodyParserOptionsTypes](#variables/DefaultJsonBodyParserOptionsTypes) | The default MIME types for the JSON Body Parser |
|
|
88
|
+
| [DefaultJsonBodyParserOptions](#variables/DefaultJsonBodyParserOptions) | The default options for the JSON Body Parser |
|
|
89
|
+
| [jsonBodyParser](#variables/jsonBodyParser) | A JSON Body Parser middleware handler initialized with the default options |
|
|
90
|
+
| [standardResponses](#variables/standardResponses) | Connect middleware to enable the transform of all responses to match the standard response format (compatible with JSON API) |
|
|
81
91
|
|
|
82
92
|
## Functions
|
|
83
93
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
94
|
+
| Function | Description |
|
|
95
|
+
| ------ | ------ |
|
|
96
|
+
| [addRouteDefinitions](#functions/addRouteDefinitions) | Registers an array of route definitions on an Express application. |
|
|
97
|
+
| [asyncHandler](#functions/asyncHandler) | Wraps an async Express request handler to forward rejected promises to the error handler. |
|
|
98
|
+
| [errorToJsonHandler](#functions/errorToJsonHandler) | Express error handler that logs the error and sends a JSON response with the error message and status code. |
|
|
99
|
+
| [getHttpHeader](#functions/getHttpHeader) | Since there can be multiple of certain HTTP headers or to prevent ugliness if someone did send us multiple instances of a header we only expect one of, this method grabs the 1st/only one of the desired header |
|
|
100
|
+
| [getDefaultLogger](#functions/getDefaultLogger) | Returns the singleton default logger instance, creating one if it does not exist. |
|
|
101
|
+
| [getLogger](#functions/getLogger) | Returns a cached Winston-backed logger at the specified verbosity level. |
|
|
102
|
+
| [compactObject](#functions/compactObject) | Returns a shallow copy of the object with all null and undefined values removed. |
|
|
103
|
+
| [~~tryParse~~](#functions/tryParse) | - |
|
|
104
|
+
| [requestHandlerValidator](#functions/requestHandlerValidator) | Factory for Express middleware that validates request and response objects using Zod schemas. |
|
|
105
|
+
| [enableCaseSensitiveRouting](#functions/enableCaseSensitiveRouting) | Enable case sensitivity. When enabled, "/Foo" and "/foo" are different routes. When disabled, "/Foo" and "/foo" are treated the same. |
|
|
106
|
+
| [disableCaseSensitiveRouting](#functions/disableCaseSensitiveRouting) | Disable case sensitivity. When enabled, "/Foo" and "/foo" are different routes. When disabled, "/Foo" and "/foo" are treated the same. |
|
|
107
|
+
| [enableExpressDefaultPoweredByHeader](#functions/enableExpressDefaultPoweredByHeader) | By default Express appends the `X-Powered-By: Express` header to all responses. Calling this method enables that behavior. |
|
|
108
|
+
| [disableExpressDefaultPoweredByHeader](#functions/disableExpressDefaultPoweredByHeader) | By default Express appends the `X-Powered-By: Express` header to all responses. Calling this method disables that behavior. |
|
|
109
|
+
| [customPoweredByHeader](#functions/customPoweredByHeader) | Express middleware that sets the X-Powered-By header to 'XYO'. |
|
|
110
|
+
| [getJsonBodyParserOptions](#functions/getJsonBodyParserOptions) | Gets the default JSON Body Parser options merged with the supplied options with the supplied options taking precedence |
|
|
111
|
+
| [getJsonBodyParser](#functions/getJsonBodyParser) | Get a JSON Body Parser connect middleware handler |
|
|
112
|
+
| [useRequestCounters](#functions/useRequestCounters) | Registers middleware that increments per-path request counters and exposes a /stats endpoint. |
|
|
113
|
+
| [responseProfiler](#functions/responseProfiler) | Connect middleware to enable profiling of response lifecycle timing. To effectively profile the response timing, this middleware needs to be called first when initializing your Express App |
|
|
114
|
+
| [getResponseMetadata](#functions/getResponseMetadata) | Extracts response metadata from res.locals, computing profile duration if profiling was started. |
|
|
115
|
+
| [standardErrors](#functions/standardErrors) | Express error handler that logs the error and sends a JSON:API-compliant error response. |
|
|
116
|
+
| [setRawResponseFormat](#functions/setRawResponseFormat) | Flags the response to forgo the standard response envelope and return the raw response body to the client |
|
|
117
|
+
| [clearRawResponseFormat](#functions/clearRawResponseFormat) | Clears any flags on the response, allowing the response to use the default standard response envelope |
|
|
118
|
+
| [isRawResponseFormatSet](#functions/isRawResponseFormatSet) | Checks if there are any flags on the response that would cause it to forgo the standard response envelope and return the raw response body to the client |
|
|
107
119
|
|
|
108
120
|
### classes
|
|
109
121
|
|
|
@@ -129,29 +141,24 @@ new Counters(): Counters;
|
|
|
129
141
|
|
|
130
142
|
## Properties
|
|
131
143
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
static counters: Record<string, number> = {};
|
|
136
|
-
```
|
|
144
|
+
| Property | Modifier | Type | Default value |
|
|
145
|
+
| ------ | ------ | ------ | ------ |
|
|
146
|
+
| <a id="counters"></a> `counters` | `static` | `Record`\<`string`, `number`\> | `{}` |
|
|
137
147
|
|
|
138
148
|
## Methods
|
|
139
149
|
|
|
140
150
|
### inc()
|
|
141
151
|
|
|
142
152
|
```ts
|
|
143
|
-
static inc(name, count
|
|
153
|
+
static inc(name: string, count?: number): void;
|
|
144
154
|
```
|
|
145
155
|
|
|
146
156
|
### Parameters
|
|
147
157
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
`string`
|
|
151
|
-
|
|
152
|
-
#### count?
|
|
153
|
-
|
|
154
|
-
`number` = `1`
|
|
158
|
+
| Parameter | Type | Default value |
|
|
159
|
+
| ------ | ------ | ------ |
|
|
160
|
+
| `name` | `string` | `undefined` |
|
|
161
|
+
| `count` | `number` | `1` |
|
|
155
162
|
|
|
156
163
|
### Returns
|
|
157
164
|
|
|
@@ -162,18 +169,15 @@ static inc(name, count?): void;
|
|
|
162
169
|
### max()
|
|
163
170
|
|
|
164
171
|
```ts
|
|
165
|
-
static max(name, count): void;
|
|
172
|
+
static max(name: string, count: number): void;
|
|
166
173
|
```
|
|
167
174
|
|
|
168
175
|
### Parameters
|
|
169
176
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
`string`
|
|
173
|
-
|
|
174
|
-
#### count
|
|
175
|
-
|
|
176
|
-
`number`
|
|
177
|
+
| Parameter | Type |
|
|
178
|
+
| ------ | ------ |
|
|
179
|
+
| `name` | `string` |
|
|
180
|
+
| `count` | `number` |
|
|
177
181
|
|
|
178
182
|
### Returns
|
|
179
183
|
|
|
@@ -184,18 +188,15 @@ static max(name, count): void;
|
|
|
184
188
|
### min()
|
|
185
189
|
|
|
186
190
|
```ts
|
|
187
|
-
static min(name, count): void;
|
|
191
|
+
static min(name: string, count: number): void;
|
|
188
192
|
```
|
|
189
193
|
|
|
190
194
|
### Parameters
|
|
191
195
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
`string`
|
|
195
|
-
|
|
196
|
-
#### count
|
|
197
|
-
|
|
198
|
-
`number`
|
|
196
|
+
| Parameter | Type |
|
|
197
|
+
| ------ | ------ |
|
|
198
|
+
| `name` | `string` |
|
|
199
|
+
| `count` | `number` |
|
|
199
200
|
|
|
200
201
|
### Returns
|
|
201
202
|
|
|
@@ -223,35 +224,30 @@ new Profiler(): Profiler;
|
|
|
223
224
|
|
|
224
225
|
## Properties
|
|
225
226
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
stats: Record<string, number> = {};
|
|
230
|
-
```
|
|
227
|
+
| Property | Type | Default value |
|
|
228
|
+
| ------ | ------ | ------ |
|
|
229
|
+
| <a id="stats"></a> `stats` | `Record`\<`string`, `number`\> | `{}` |
|
|
231
230
|
|
|
232
231
|
## Methods
|
|
233
232
|
|
|
234
233
|
### profile()
|
|
235
234
|
|
|
236
235
|
```ts
|
|
237
|
-
profile<T>(name, promise): Promise<T>;
|
|
236
|
+
profile<T>(name: string, promise: Promise<T>): Promise<T>;
|
|
238
237
|
```
|
|
239
238
|
|
|
240
239
|
### Type Parameters
|
|
241
240
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
`T`
|
|
241
|
+
| Type Parameter |
|
|
242
|
+
| ------ |
|
|
243
|
+
| `T` |
|
|
245
244
|
|
|
246
245
|
### Parameters
|
|
247
246
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
`string`
|
|
251
|
-
|
|
252
|
-
#### promise
|
|
253
|
-
|
|
254
|
-
`Promise`\<`T`\>
|
|
247
|
+
| Parameter | Type |
|
|
248
|
+
| ------ | ------ |
|
|
249
|
+
| `name` | `string` |
|
|
250
|
+
| `promise` | `Promise`\<`T`\> |
|
|
255
251
|
|
|
256
252
|
### Returns
|
|
257
253
|
|
|
@@ -275,14 +271,14 @@ console logging methods
|
|
|
275
271
|
### Constructor
|
|
276
272
|
|
|
277
273
|
```ts
|
|
278
|
-
new WrappedWinstonLogger(winston): WrappedWinstonLogger;
|
|
274
|
+
new WrappedWinstonLogger(winston: Logger): WrappedWinstonLogger;
|
|
279
275
|
```
|
|
280
276
|
|
|
281
277
|
### Parameters
|
|
282
278
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
`Logger`
|
|
279
|
+
| Parameter | Type |
|
|
280
|
+
| ------ | ------ |
|
|
281
|
+
| `winston` | `Logger` |
|
|
286
282
|
|
|
287
283
|
### Returns
|
|
288
284
|
|
|
@@ -290,95 +286,15 @@ new WrappedWinstonLogger(winston): WrappedWinstonLogger;
|
|
|
290
286
|
|
|
291
287
|
## Properties
|
|
292
288
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
```ts
|
|
304
|
-
debug: LogFunction;
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
### Implementation of
|
|
308
|
-
|
|
309
|
-
```ts
|
|
310
|
-
Logger.debug
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
***
|
|
314
|
-
|
|
315
|
-
### error
|
|
316
|
-
|
|
317
|
-
```ts
|
|
318
|
-
error: LogFunction;
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
### Implementation of
|
|
322
|
-
|
|
323
|
-
```ts
|
|
324
|
-
Logger.error
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
***
|
|
328
|
-
|
|
329
|
-
### info
|
|
330
|
-
|
|
331
|
-
```ts
|
|
332
|
-
info: LogFunction;
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
### Implementation of
|
|
336
|
-
|
|
337
|
-
```ts
|
|
338
|
-
Logger.info
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
***
|
|
342
|
-
|
|
343
|
-
### log
|
|
344
|
-
|
|
345
|
-
```ts
|
|
346
|
-
log: LogFunction;
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
### Implementation of
|
|
350
|
-
|
|
351
|
-
```ts
|
|
352
|
-
Logger.log
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
***
|
|
356
|
-
|
|
357
|
-
### trace
|
|
358
|
-
|
|
359
|
-
```ts
|
|
360
|
-
trace: LogFunction;
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
### Implementation of
|
|
364
|
-
|
|
365
|
-
```ts
|
|
366
|
-
Logger.trace
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
***
|
|
370
|
-
|
|
371
|
-
### warn
|
|
372
|
-
|
|
373
|
-
```ts
|
|
374
|
-
warn: LogFunction;
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
### Implementation of
|
|
378
|
-
|
|
379
|
-
```ts
|
|
380
|
-
Logger.warn
|
|
381
|
-
```
|
|
289
|
+
| Property | Modifier | Type |
|
|
290
|
+
| ------ | ------ | ------ |
|
|
291
|
+
| <a id="winston"></a> `winston` | `readonly` | `Logger` |
|
|
292
|
+
| <a id="debug"></a> `debug` | `public` | `LogFunction` |
|
|
293
|
+
| <a id="error"></a> `error` | `public` | `LogFunction` |
|
|
294
|
+
| <a id="info"></a> `info` | `public` | `LogFunction` |
|
|
295
|
+
| <a id="log"></a> `log` | `public` | `LogFunction` |
|
|
296
|
+
| <a id="trace"></a> `trace` | `public` | `LogFunction` |
|
|
297
|
+
| <a id="warn"></a> `warn` | `public` | `LogFunction` |
|
|
382
298
|
|
|
383
299
|
### functions
|
|
384
300
|
|
|
@@ -389,24 +305,17 @@ Logger.warn
|
|
|
389
305
|
***
|
|
390
306
|
|
|
391
307
|
```ts
|
|
392
|
-
function addRouteDefinitions(app, routeDefinitions): void;
|
|
308
|
+
function addRouteDefinitions(app: Express, routeDefinitions: RouteDefinition<RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>>[]): void;
|
|
393
309
|
```
|
|
394
310
|
|
|
395
311
|
Registers an array of route definitions on an Express application.
|
|
396
312
|
|
|
397
313
|
## Parameters
|
|
398
314
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
`Express`
|
|
402
|
-
|
|
403
|
-
The Express application to register routes on.
|
|
404
|
-
|
|
405
|
-
### routeDefinitions
|
|
406
|
-
|
|
407
|
-
[`RouteDefinition`](#../interfaces/RouteDefinition)\<`RequestHandler`\<`ParamsDictionary`, `any`, `any`, `ParsedQs`, `Record`\<`string`, `any`\>\>\>[]
|
|
408
|
-
|
|
409
|
-
The route definitions to register.
|
|
315
|
+
| Parameter | Type | Description |
|
|
316
|
+
| ------ | ------ | ------ |
|
|
317
|
+
| `app` | `Express` | The Express application to register routes on. |
|
|
318
|
+
| `routeDefinitions` | [`RouteDefinition`](#../interfaces/RouteDefinition)\<`RequestHandler`\<`ParamsDictionary`, `any`, `any`, `ParsedQs`, `Record`\<`string`, `any`\>\>\>[] | The route definitions to register. |
|
|
410
319
|
|
|
411
320
|
## Returns
|
|
412
321
|
|
|
@@ -419,40 +328,26 @@ The route definitions to register.
|
|
|
419
328
|
***
|
|
420
329
|
|
|
421
330
|
```ts
|
|
422
|
-
function asyncHandler<P, ResBody, ReqBody, ReqQuery, Locals>(fn): (req, res, next) => Promise<unknown>;
|
|
331
|
+
function asyncHandler<P, ResBody, ReqBody, ReqQuery, Locals>(fn: RequestHandler<P, ResBody, ReqBody, ReqQuery, Locals>): (req: Request<P, ResBody, ReqBody, ReqQuery, Locals>, res: Response<ResBody, Locals>, next: NextFunction) => Promise<unknown>;
|
|
423
332
|
```
|
|
424
333
|
|
|
425
334
|
Wraps an async Express request handler to forward rejected promises to the error handler.
|
|
426
335
|
|
|
427
336
|
## Type Parameters
|
|
428
337
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
`P`
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
`
|
|
436
|
-
|
|
437
|
-
### ReqBody
|
|
438
|
-
|
|
439
|
-
`ReqBody` = [`Empty`](#../interfaces/Empty)
|
|
440
|
-
|
|
441
|
-
### ReqQuery
|
|
442
|
-
|
|
443
|
-
`ReqQuery` = `ParsedQs`
|
|
444
|
-
|
|
445
|
-
### Locals
|
|
446
|
-
|
|
447
|
-
`Locals` *extends* [`NoLocals`](#../type-aliases/NoLocals) = [`NoLocals`](#../type-aliases/NoLocals)
|
|
338
|
+
| Type Parameter | Default type |
|
|
339
|
+
| ------ | ------ |
|
|
340
|
+
| `P` | `ParamsDictionary` |
|
|
341
|
+
| `ResBody` | [`Empty`](#../interfaces/Empty) |
|
|
342
|
+
| `ReqBody` | [`Empty`](#../interfaces/Empty) |
|
|
343
|
+
| `ReqQuery` | `ParsedQs` |
|
|
344
|
+
| `Locals` *extends* [`NoLocals`](#../type-aliases/NoLocals) | [`NoLocals`](#../type-aliases/NoLocals) |
|
|
448
345
|
|
|
449
346
|
## Parameters
|
|
450
347
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
`RequestHandler`\<`P`, `ResBody`, `ReqBody`, `ReqQuery`, `Locals`\>
|
|
454
|
-
|
|
455
|
-
The async request handler to wrap.
|
|
348
|
+
| Parameter | Type | Description |
|
|
349
|
+
| ------ | ------ | ------ |
|
|
350
|
+
| `fn` | `RequestHandler`\<`P`, `ResBody`, `ReqBody`, `ReqQuery`, `Locals`\> | The async request handler to wrap. |
|
|
456
351
|
|
|
457
352
|
## Returns
|
|
458
353
|
|
|
@@ -460,24 +355,18 @@ A request handler that catches async errors and passes them to next().
|
|
|
460
355
|
|
|
461
356
|
```ts
|
|
462
357
|
(
|
|
463
|
-
req,
|
|
464
|
-
res,
|
|
465
|
-
next): Promise<unknown>;
|
|
358
|
+
req: Request<P, ResBody, ReqBody, ReqQuery, Locals>,
|
|
359
|
+
res: Response<ResBody, Locals>,
|
|
360
|
+
next: NextFunction): Promise<unknown>;
|
|
466
361
|
```
|
|
467
362
|
|
|
468
363
|
### Parameters
|
|
469
364
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
`Request`\<`P`, `ResBody`, `ReqBody`, `ReqQuery`, `Locals`\>
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
`Response`\<`ResBody`, `Locals`\>
|
|
477
|
-
|
|
478
|
-
### next
|
|
479
|
-
|
|
480
|
-
`NextFunction`
|
|
365
|
+
| Parameter | Type |
|
|
366
|
+
| ------ | ------ |
|
|
367
|
+
| `req` | `Request`\<`P`, `ResBody`, `ReqBody`, `ReqQuery`, `Locals`\> |
|
|
368
|
+
| `res` | `Response`\<`ResBody`, `Locals`\> |
|
|
369
|
+
| `next` | `NextFunction` |
|
|
481
370
|
|
|
482
371
|
### Returns
|
|
483
372
|
|
|
@@ -490,7 +379,7 @@ next): Promise<unknown>;
|
|
|
490
379
|
***
|
|
491
380
|
|
|
492
381
|
```ts
|
|
493
|
-
function clearRawResponseFormat(res): void;
|
|
382
|
+
function clearRawResponseFormat(res: Response): void;
|
|
494
383
|
```
|
|
495
384
|
|
|
496
385
|
Clears any flags on the response, allowing the response to
|
|
@@ -498,11 +387,9 @@ use the default standard response envelope
|
|
|
498
387
|
|
|
499
388
|
## Parameters
|
|
500
389
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
`Response`
|
|
504
|
-
|
|
505
|
-
The response to set to the standard response format
|
|
390
|
+
| Parameter | Type | Description |
|
|
391
|
+
| ------ | ------ | ------ |
|
|
392
|
+
| `res` | `Response` | The response to set to the standard response format |
|
|
506
393
|
|
|
507
394
|
## Returns
|
|
508
395
|
|
|
@@ -515,24 +402,22 @@ The response to set to the standard response format
|
|
|
515
402
|
***
|
|
516
403
|
|
|
517
404
|
```ts
|
|
518
|
-
function compactObject<T>(obj): T;
|
|
405
|
+
function compactObject<T>(obj: T): T;
|
|
519
406
|
```
|
|
520
407
|
|
|
521
408
|
Returns a shallow copy of the object with all null and undefined values removed.
|
|
522
409
|
|
|
523
410
|
## Type Parameters
|
|
524
411
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
`T` *extends* `Record`\<`string`, `unknown`\>
|
|
412
|
+
| Type Parameter |
|
|
413
|
+
| ------ |
|
|
414
|
+
| `T` *extends* `Record`\<`string`, `unknown`\> |
|
|
528
415
|
|
|
529
416
|
## Parameters
|
|
530
417
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
`T`
|
|
534
|
-
|
|
535
|
-
The object to compact.
|
|
418
|
+
| Parameter | Type | Description |
|
|
419
|
+
| ------ | ------ | ------ |
|
|
420
|
+
| `obj` | `T` | The object to compact. |
|
|
536
421
|
|
|
537
422
|
## Returns
|
|
538
423
|
|
|
@@ -548,26 +433,20 @@ A new object with only defined, non-null properties.
|
|
|
548
433
|
|
|
549
434
|
```ts
|
|
550
435
|
function customPoweredByHeader(
|
|
551
|
-
req,
|
|
552
|
-
res,
|
|
553
|
-
next): void;
|
|
436
|
+
req: Request,
|
|
437
|
+
res: Response,
|
|
438
|
+
next: NextFunction): void;
|
|
554
439
|
```
|
|
555
440
|
|
|
556
441
|
Express middleware that sets the X-Powered-By header to 'XYO'.
|
|
557
442
|
|
|
558
443
|
## Parameters
|
|
559
444
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
`Request`
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
`Response`
|
|
567
|
-
|
|
568
|
-
### next
|
|
569
|
-
|
|
570
|
-
`NextFunction`
|
|
445
|
+
| Parameter | Type |
|
|
446
|
+
| ------ | ------ |
|
|
447
|
+
| `req` | `Request` |
|
|
448
|
+
| `res` | `Response` |
|
|
449
|
+
| `next` | `NextFunction` |
|
|
571
450
|
|
|
572
451
|
## Returns
|
|
573
452
|
|
|
@@ -580,7 +459,7 @@ Express middleware that sets the X-Powered-By header to 'XYO'.
|
|
|
580
459
|
***
|
|
581
460
|
|
|
582
461
|
```ts
|
|
583
|
-
function disableCaseSensitiveRouting(app): void;
|
|
462
|
+
function disableCaseSensitiveRouting(app: Express): void;
|
|
584
463
|
```
|
|
585
464
|
|
|
586
465
|
Disable case sensitivity. When enabled, "/Foo" and "/foo" are different
|
|
@@ -588,11 +467,9 @@ routes. When disabled, "/Foo" and "/foo" are treated the same.
|
|
|
588
467
|
|
|
589
468
|
## Parameters
|
|
590
469
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
`Express`
|
|
594
|
-
|
|
595
|
-
The Express app to disable the header on.
|
|
470
|
+
| Parameter | Type | Description |
|
|
471
|
+
| ------ | ------ | ------ |
|
|
472
|
+
| `app` | `Express` | The Express app to disable the header on. |
|
|
596
473
|
|
|
597
474
|
## Returns
|
|
598
475
|
|
|
@@ -605,7 +482,7 @@ The Express app to disable the header on.
|
|
|
605
482
|
***
|
|
606
483
|
|
|
607
484
|
```ts
|
|
608
|
-
function disableExpressDefaultPoweredByHeader(app): void;
|
|
485
|
+
function disableExpressDefaultPoweredByHeader(app: Express): void;
|
|
609
486
|
```
|
|
610
487
|
|
|
611
488
|
By default Express appends the `X-Powered-By: Express` header to
|
|
@@ -613,11 +490,9 @@ all responses. Calling this method disables that behavior.
|
|
|
613
490
|
|
|
614
491
|
## Parameters
|
|
615
492
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
`Express`
|
|
619
|
-
|
|
620
|
-
The Express app to disable the header on.
|
|
493
|
+
| Parameter | Type | Description |
|
|
494
|
+
| ------ | ------ | ------ |
|
|
495
|
+
| `app` | `Express` | The Express app to disable the header on. |
|
|
621
496
|
|
|
622
497
|
## Returns
|
|
623
498
|
|
|
@@ -630,7 +505,7 @@ The Express app to disable the header on.
|
|
|
630
505
|
***
|
|
631
506
|
|
|
632
507
|
```ts
|
|
633
|
-
function enableCaseSensitiveRouting(app): void;
|
|
508
|
+
function enableCaseSensitiveRouting(app: Express): void;
|
|
634
509
|
```
|
|
635
510
|
|
|
636
511
|
Enable case sensitivity. When enabled, "/Foo" and "/foo" are different
|
|
@@ -638,11 +513,9 @@ routes. When disabled, "/Foo" and "/foo" are treated the same.
|
|
|
638
513
|
|
|
639
514
|
## Parameters
|
|
640
515
|
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
`Express`
|
|
644
|
-
|
|
645
|
-
The Express app to disable the header on.
|
|
516
|
+
| Parameter | Type | Description |
|
|
517
|
+
| ------ | ------ | ------ |
|
|
518
|
+
| `app` | `Express` | The Express app to disable the header on. |
|
|
646
519
|
|
|
647
520
|
## Returns
|
|
648
521
|
|
|
@@ -655,7 +528,7 @@ The Express app to disable the header on.
|
|
|
655
528
|
***
|
|
656
529
|
|
|
657
530
|
```ts
|
|
658
|
-
function enableExpressDefaultPoweredByHeader(app): void;
|
|
531
|
+
function enableExpressDefaultPoweredByHeader(app: Express): void;
|
|
659
532
|
```
|
|
660
533
|
|
|
661
534
|
By default Express appends the `X-Powered-By: Express` header to
|
|
@@ -663,11 +536,9 @@ all responses. Calling this method enables that behavior.
|
|
|
663
536
|
|
|
664
537
|
## Parameters
|
|
665
538
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
`Express`
|
|
669
|
-
|
|
670
|
-
The Express app to disable the header on.
|
|
539
|
+
| Parameter | Type | Description |
|
|
540
|
+
| ------ | ------ | ------ |
|
|
541
|
+
| `app` | `Express` | The Express app to disable the header on. |
|
|
671
542
|
|
|
672
543
|
## Returns
|
|
673
544
|
|
|
@@ -681,39 +552,22 @@ The Express app to disable the header on.
|
|
|
681
552
|
|
|
682
553
|
```ts
|
|
683
554
|
function errorToJsonHandler(
|
|
684
|
-
error,
|
|
685
|
-
req,
|
|
686
|
-
res,
|
|
687
|
-
next): void;
|
|
555
|
+
error: ExpressError,
|
|
556
|
+
req: Request,
|
|
557
|
+
res: Response,
|
|
558
|
+
next: NextFunction): void;
|
|
688
559
|
```
|
|
689
560
|
|
|
690
561
|
Express error handler that logs the error and sends a JSON response with the error message and status code.
|
|
691
562
|
|
|
692
563
|
## Parameters
|
|
693
564
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
[`ExpressError`](#../interfaces/ExpressError)
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
### req
|
|
701
|
-
|
|
702
|
-
`Request`
|
|
703
|
-
|
|
704
|
-
The incoming request.
|
|
705
|
-
|
|
706
|
-
### res
|
|
707
|
-
|
|
708
|
-
`Response`
|
|
709
|
-
|
|
710
|
-
The outgoing response.
|
|
711
|
-
|
|
712
|
-
### next
|
|
713
|
-
|
|
714
|
-
`NextFunction`
|
|
715
|
-
|
|
716
|
-
The next middleware function.
|
|
565
|
+
| Parameter | Type | Description |
|
|
566
|
+
| ------ | ------ | ------ |
|
|
567
|
+
| `error` | [`ExpressError`](#../interfaces/ExpressError) | The Express error to handle. |
|
|
568
|
+
| `req` | `Request` | The incoming request. |
|
|
569
|
+
| `res` | `Response` | The outgoing response. |
|
|
570
|
+
| `next` | `NextFunction` | The next middleware function. |
|
|
717
571
|
|
|
718
572
|
## Returns
|
|
719
573
|
|
|
@@ -744,7 +598,7 @@ The default logger.
|
|
|
744
598
|
***
|
|
745
599
|
|
|
746
600
|
```ts
|
|
747
|
-
function getHttpHeader(header, req): string | undefined;
|
|
601
|
+
function getHttpHeader(header: string, req: Request): string | undefined;
|
|
748
602
|
```
|
|
749
603
|
|
|
750
604
|
Since there can be multiple of certain HTTP headers or
|
|
@@ -754,17 +608,10 @@ method grabs the 1st/only one of the desired header
|
|
|
754
608
|
|
|
755
609
|
## Parameters
|
|
756
610
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
`string`
|
|
760
|
-
|
|
761
|
-
The header to find
|
|
762
|
-
|
|
763
|
-
### req
|
|
764
|
-
|
|
765
|
-
`Request`
|
|
766
|
-
|
|
767
|
-
The received HTTP request (with headers)
|
|
611
|
+
| Parameter | Type | Description |
|
|
612
|
+
| ------ | ------ | ------ |
|
|
613
|
+
| `header` | `string` | The header to find |
|
|
614
|
+
| `req` | `Request` | The received HTTP request (with headers) |
|
|
768
615
|
|
|
769
616
|
## Returns
|
|
770
617
|
|
|
@@ -779,18 +626,16 @@ The first or only occurrence of the specified HTTP header
|
|
|
779
626
|
***
|
|
780
627
|
|
|
781
628
|
```ts
|
|
782
|
-
function getJsonBodyParser(options
|
|
629
|
+
function getJsonBodyParser(options?: OptionsJson): NextHandleFunction;
|
|
783
630
|
```
|
|
784
631
|
|
|
785
632
|
Get a JSON Body Parser connect middleware handler
|
|
786
633
|
|
|
787
634
|
## Parameters
|
|
788
635
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
`OptionsJson`
|
|
792
|
-
|
|
793
|
-
The options for the JSON Body Parser
|
|
636
|
+
| Parameter | Type | Default value | Description |
|
|
637
|
+
| ------ | ------ | ------ | ------ |
|
|
638
|
+
| `options` | `OptionsJson` | `DefaultJsonBodyParserOptions` | The options for the JSON Body Parser |
|
|
794
639
|
|
|
795
640
|
## Returns
|
|
796
641
|
|
|
@@ -805,7 +650,7 @@ A middleware function that parses JSON bodies
|
|
|
805
650
|
***
|
|
806
651
|
|
|
807
652
|
```ts
|
|
808
|
-
function getJsonBodyParserOptions(options
|
|
653
|
+
function getJsonBodyParserOptions(options?: Partial<OptionsJson>): OptionsJson;
|
|
809
654
|
```
|
|
810
655
|
|
|
811
656
|
Gets the default JSON Body Parser options merged with the supplied options
|
|
@@ -813,11 +658,9 @@ with the supplied options taking precedence
|
|
|
813
658
|
|
|
814
659
|
## Parameters
|
|
815
660
|
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
`Partial`\<`OptionsJson`\>
|
|
819
|
-
|
|
820
|
-
The options to override the default JSON Body Parser options with
|
|
661
|
+
| Parameter | Type | Description |
|
|
662
|
+
| ------ | ------ | ------ |
|
|
663
|
+
| `options?` | `Partial`\<`OptionsJson`\> | The options to override the default JSON Body Parser options with |
|
|
821
664
|
|
|
822
665
|
## Returns
|
|
823
666
|
|
|
@@ -833,18 +676,16 @@ precedence over the default
|
|
|
833
676
|
***
|
|
834
677
|
|
|
835
678
|
```ts
|
|
836
|
-
function getLogger(minVerbosity
|
|
679
|
+
function getLogger(minVerbosity?: LoggerVerbosity): Logger;
|
|
837
680
|
```
|
|
838
681
|
|
|
839
682
|
Returns a cached Winston-backed logger at the specified verbosity level.
|
|
840
683
|
|
|
841
684
|
## Parameters
|
|
842
685
|
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
[`LoggerVerbosity`](#../type-aliases/LoggerVerbosity)
|
|
846
|
-
|
|
847
|
-
The minimum log level to output. Defaults to 'info'.
|
|
686
|
+
| Parameter | Type | Default value | Description |
|
|
687
|
+
| ------ | ------ | ------ | ------ |
|
|
688
|
+
| `minVerbosity` | [`LoggerVerbosity`](#../type-aliases/LoggerVerbosity) | `'info'` | The minimum log level to output. Defaults to 'info'. |
|
|
848
689
|
|
|
849
690
|
## Returns
|
|
850
691
|
|
|
@@ -859,18 +700,16 @@ A logger instance configured for the given verbosity.
|
|
|
859
700
|
***
|
|
860
701
|
|
|
861
702
|
```ts
|
|
862
|
-
function getResponseMetadata(res): Record<string, unknown>;
|
|
703
|
+
function getResponseMetadata(res: Response): Record<string, unknown>;
|
|
863
704
|
```
|
|
864
705
|
|
|
865
706
|
Extracts response metadata from res.locals, computing profile duration if profiling was started.
|
|
866
707
|
|
|
867
708
|
## Parameters
|
|
868
709
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
`Response`
|
|
872
|
-
|
|
873
|
-
The Express response to extract metadata from.
|
|
710
|
+
| Parameter | Type | Description |
|
|
711
|
+
| ------ | ------ | ------ |
|
|
712
|
+
| `res` | `Response` | The Express response to extract metadata from. |
|
|
874
713
|
|
|
875
714
|
## Returns
|
|
876
715
|
|
|
@@ -885,7 +724,7 @@ The metadata record including any profiling information.
|
|
|
885
724
|
***
|
|
886
725
|
|
|
887
726
|
```ts
|
|
888
|
-
function isRawResponseFormatSet(res): boolean;
|
|
727
|
+
function isRawResponseFormatSet(res: Response): boolean;
|
|
889
728
|
```
|
|
890
729
|
|
|
891
730
|
Checks if there are any flags on the response that would cause it
|
|
@@ -894,9 +733,9 @@ body to the client
|
|
|
894
733
|
|
|
895
734
|
## Parameters
|
|
896
735
|
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
`Response`
|
|
736
|
+
| Parameter | Type | Description |
|
|
737
|
+
| ------ | ------ | ------ |
|
|
738
|
+
| `res` | `Response` | - |
|
|
900
739
|
|
|
901
740
|
## Returns
|
|
902
741
|
|
|
@@ -911,63 +750,44 @@ True if there are any flags on the response, false otherwise
|
|
|
911
750
|
***
|
|
912
751
|
|
|
913
752
|
```ts
|
|
914
|
-
function requestHandlerValidator<TParams, TQuery, TBody, TResponse>(schemas
|
|
753
|
+
function requestHandlerValidator<TParams, TQuery, TBody, TResponse>(schemas?: Partial<{
|
|
754
|
+
body: TBody;
|
|
755
|
+
params: TParams;
|
|
756
|
+
query: TQuery;
|
|
757
|
+
response: TResponse;
|
|
758
|
+
}>): (handler: (req: Request<output<TParams>, output<TResponse>, output<TBody>, output<TQuery>>, res: Response<output<TResponse>>, next: NextFunction) => unknown) => RequestHandler;
|
|
915
759
|
```
|
|
916
760
|
|
|
917
761
|
Factory for Express middleware that validates request and response objects using Zod schemas.
|
|
918
762
|
|
|
919
763
|
## Type Parameters
|
|
920
764
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
`TParams` *extends*
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
\}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\>
|
|
928
|
-
|
|
929
|
-
### TQuery
|
|
930
|
-
|
|
931
|
-
`TQuery` *extends*
|
|
932
|
-
\| `ZodObject`\<\{
|
|
933
|
-
\}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\>
|
|
934
|
-
\| `ZodType`\<`Record`\<`string`, `string` \| `string`[]\>, `unknown`, `$ZodTypeInternals`\<`Record`\<`string`, `string` \| `string`[]\>, `unknown`\>\> = `ZodObject`\<\{
|
|
935
|
-
\}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\>
|
|
936
|
-
|
|
937
|
-
### TBody
|
|
938
|
-
|
|
939
|
-
`TBody` *extends* `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> = `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\>
|
|
940
|
-
|
|
941
|
-
### TResponse
|
|
942
|
-
|
|
943
|
-
`TResponse` *extends* `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> = `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\>
|
|
765
|
+
| Type Parameter | Default type |
|
|
766
|
+
| ------ | ------ |
|
|
767
|
+
| `TParams` *extends* \| `ZodObject`\<\{ \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> \| `ZodType`\<`Record`\<`string`, `string`\>, `unknown`, `$ZodTypeInternals`\<`Record`\<`string`, `string`\>, `unknown`\>\> | `ZodObject`\<\{ \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> |
|
|
768
|
+
| `TQuery` *extends* \| `ZodObject`\<\{ \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> \| `ZodType`\<`Record`\<`string`, `string` \| `string`[]\>, `unknown`, `$ZodTypeInternals`\<`Record`\<`string`, `string` \| `string`[]\>, `unknown`\>\> | `ZodObject`\<\{ \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> |
|
|
769
|
+
| `TBody` *extends* `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> | `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> |
|
|
770
|
+
| `TResponse` *extends* `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> | `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> |
|
|
944
771
|
|
|
945
772
|
## Parameters
|
|
946
773
|
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
`Partial`\<\{
|
|
950
|
-
`body`: `TBody`;
|
|
951
|
-
`params`: `TParams`;
|
|
952
|
-
`query`: `TQuery`;
|
|
953
|
-
`response`: `TResponse`;
|
|
954
|
-
\}\>
|
|
955
|
-
|
|
956
|
-
The Zod schemas to use for validation.
|
|
774
|
+
| Parameter | Type | Description |
|
|
775
|
+
| ------ | ------ | ------ |
|
|
776
|
+
| `schemas?` | `Partial`\<\{ `body`: `TBody`; `params`: `TParams`; `query`: `TQuery`; `response`: `TResponse`; \}\> | The Zod schemas to use for validation. |
|
|
957
777
|
|
|
958
778
|
## Returns
|
|
959
779
|
|
|
960
780
|
A middleware function for validating requests and responses.
|
|
961
781
|
|
|
962
782
|
```ts
|
|
963
|
-
(handler): RequestHandler;
|
|
783
|
+
(handler: (req: Request<output<TParams>, output<TResponse>, output<TBody>, output<TQuery>>, res: Response<output<TResponse>>, next: NextFunction) => unknown): RequestHandler;
|
|
964
784
|
```
|
|
965
785
|
|
|
966
786
|
### Parameters
|
|
967
787
|
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
(`req
|
|
788
|
+
| Parameter | Type |
|
|
789
|
+
| ------ | ------ |
|
|
790
|
+
| `handler` | (`req`: `Request`\<`output`\<`TParams`\>, `output`\<`TResponse`\>, `output`\<`TBody`\>, `output`\<`TQuery`\>\>, `res`: `Response`\<`output`\<`TResponse`\>\>, `next`: `NextFunction`) => `unknown` |
|
|
971
791
|
|
|
972
792
|
### Returns
|
|
973
793
|
|
|
@@ -981,9 +801,9 @@ A middleware function for validating requests and responses.
|
|
|
981
801
|
|
|
982
802
|
```ts
|
|
983
803
|
function responseProfiler(
|
|
984
|
-
_req,
|
|
985
|
-
res,
|
|
986
|
-
next): void;
|
|
804
|
+
_req: Request,
|
|
805
|
+
res: Response,
|
|
806
|
+
next: NextFunction): void;
|
|
987
807
|
```
|
|
988
808
|
|
|
989
809
|
Connect middleware to enable profiling of response lifecycle timing. To effectively profile
|
|
@@ -992,23 +812,11 @@ App
|
|
|
992
812
|
|
|
993
813
|
## Parameters
|
|
994
814
|
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
`Request`
|
|
998
|
-
|
|
999
|
-
The
|
|
1000
|
-
|
|
1001
|
-
### res
|
|
1002
|
-
|
|
1003
|
-
`Response`
|
|
1004
|
-
|
|
1005
|
-
The response
|
|
1006
|
-
|
|
1007
|
-
### next
|
|
1008
|
-
|
|
1009
|
-
`NextFunction`
|
|
1010
|
-
|
|
1011
|
-
The next function
|
|
815
|
+
| Parameter | Type | Description |
|
|
816
|
+
| ------ | ------ | ------ |
|
|
817
|
+
| `_req` | `Request` | The request |
|
|
818
|
+
| `res` | `Response` | The response |
|
|
819
|
+
| `next` | `NextFunction` | The next function |
|
|
1012
820
|
|
|
1013
821
|
## Returns
|
|
1014
822
|
|
|
@@ -1029,7 +837,7 @@ app.use(responseProfiler)
|
|
|
1029
837
|
***
|
|
1030
838
|
|
|
1031
839
|
```ts
|
|
1032
|
-
function setRawResponseFormat(res): void;
|
|
840
|
+
function setRawResponseFormat(res: Response): void;
|
|
1033
841
|
```
|
|
1034
842
|
|
|
1035
843
|
Flags the response to forgo the standard response envelope
|
|
@@ -1037,11 +845,9 @@ and return the raw response body to the client
|
|
|
1037
845
|
|
|
1038
846
|
## Parameters
|
|
1039
847
|
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
`Response`
|
|
1043
|
-
|
|
1044
|
-
The response to disable the standard response format on
|
|
848
|
+
| Parameter | Type | Description |
|
|
849
|
+
| ------ | ------ | ------ |
|
|
850
|
+
| `res` | `Response` | The response to disable the standard response format on |
|
|
1045
851
|
|
|
1046
852
|
## Returns
|
|
1047
853
|
|
|
@@ -1055,39 +861,22 @@ The response to disable the standard response format on
|
|
|
1055
861
|
|
|
1056
862
|
```ts
|
|
1057
863
|
function standardErrors(
|
|
1058
|
-
err,
|
|
1059
|
-
req,
|
|
1060
|
-
res,
|
|
1061
|
-
next): void;
|
|
864
|
+
err: ExpressError | undefined,
|
|
865
|
+
req: Request,
|
|
866
|
+
res: Response,
|
|
867
|
+
next: NextFunction): void;
|
|
1062
868
|
```
|
|
1063
869
|
|
|
1064
870
|
Express error handler that logs the error and sends a JSON:API-compliant error response.
|
|
1065
871
|
|
|
1066
872
|
## Parameters
|
|
1067
873
|
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
The error to handle, or undefined if no error.
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
### req
|
|
1075
|
-
|
|
1076
|
-
`Request`
|
|
1077
|
-
|
|
1078
|
-
The incoming request.
|
|
1079
|
-
|
|
1080
|
-
### res
|
|
1081
|
-
|
|
1082
|
-
`Response`
|
|
1083
|
-
|
|
1084
|
-
The outgoing response.
|
|
1085
|
-
|
|
1086
|
-
### next
|
|
1087
|
-
|
|
1088
|
-
`NextFunction`
|
|
1089
|
-
|
|
1090
|
-
The next middleware function.
|
|
874
|
+
| Parameter | Type | Description |
|
|
875
|
+
| ------ | ------ | ------ |
|
|
876
|
+
| `err` | [`ExpressError`](#../interfaces/ExpressError) \| `undefined` | The error to handle, or undefined if no error. |
|
|
877
|
+
| `req` | `Request` | The incoming request. |
|
|
878
|
+
| `res` | `Response` | The outgoing response. |
|
|
879
|
+
| `next` | `NextFunction` | The next middleware function. |
|
|
1091
880
|
|
|
1092
881
|
## Returns
|
|
1093
882
|
|
|
@@ -1100,28 +889,30 @@ The next middleware function.
|
|
|
1100
889
|
***
|
|
1101
890
|
|
|
1102
891
|
```ts
|
|
1103
|
-
function tryParse<T>(func
|
|
892
|
+
function tryParse<T>(func: ParseFunc<T>, value?: string):
|
|
893
|
+
| T & {
|
|
894
|
+
}
|
|
895
|
+
| undefined;
|
|
1104
896
|
```
|
|
1105
897
|
|
|
1106
898
|
## Type Parameters
|
|
1107
899
|
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
`T`
|
|
900
|
+
| Type Parameter | Default type |
|
|
901
|
+
| ------ | ------ |
|
|
902
|
+
| `T` | `number` |
|
|
1111
903
|
|
|
1112
904
|
## Parameters
|
|
1113
905
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
[`ParseFunc`](#../type-aliases/ParseFunc)\<`T`\>
|
|
1117
|
-
|
|
1118
|
-
### value?
|
|
1119
|
-
|
|
1120
|
-
`string`
|
|
906
|
+
| Parameter | Type |
|
|
907
|
+
| ------ | ------ |
|
|
908
|
+
| `func` | [`ParseFunc`](#../type-aliases/ParseFunc)\<`T`\> |
|
|
909
|
+
| `value?` | `string` |
|
|
1121
910
|
|
|
1122
911
|
## Returns
|
|
1123
912
|
|
|
1124
|
-
`T` &
|
|
913
|
+
\| `T` & \{
|
|
914
|
+
\}
|
|
915
|
+
\| `undefined`
|
|
1125
916
|
|
|
1126
917
|
## Deprecated
|
|
1127
918
|
|
|
@@ -1134,18 +925,16 @@ use zod instead
|
|
|
1134
925
|
***
|
|
1135
926
|
|
|
1136
927
|
```ts
|
|
1137
|
-
function useRequestCounters(app): void;
|
|
928
|
+
function useRequestCounters(app: Application): void;
|
|
1138
929
|
```
|
|
1139
930
|
|
|
1140
931
|
Registers middleware that increments per-path request counters and exposes a /stats endpoint.
|
|
1141
932
|
|
|
1142
933
|
## Parameters
|
|
1143
934
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
`Application`
|
|
1147
|
-
|
|
1148
|
-
The Express application to attach counters to.
|
|
935
|
+
| Parameter | Type | Description |
|
|
936
|
+
| ------ | ------ | ------ |
|
|
937
|
+
| `app` | `Application` | The Express application to attach counters to. |
|
|
1149
938
|
|
|
1150
939
|
## Returns
|
|
1151
940
|
|
|
@@ -1167,61 +956,19 @@ A successful JSON:API response containing primary data and optional included res
|
|
|
1167
956
|
|
|
1168
957
|
## Type Parameters
|
|
1169
958
|
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
`T` *extends* [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject)
|
|
959
|
+
| Type Parameter |
|
|
960
|
+
| ------ |
|
|
961
|
+
| `T` *extends* [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject) |
|
|
1173
962
|
|
|
1174
963
|
## Properties
|
|
1175
964
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
[`ApiResponseBase`](#ApiResponseBase).[`jsonapi`](ApiResponseBase.md#jsonapi)
|
|
1185
|
-
|
|
1186
|
-
***
|
|
1187
|
-
|
|
1188
|
-
### links?
|
|
1189
|
-
|
|
1190
|
-
```ts
|
|
1191
|
-
optional links: ApiLinks;
|
|
1192
|
-
```
|
|
1193
|
-
|
|
1194
|
-
### Inherited from
|
|
1195
|
-
|
|
1196
|
-
[`ApiResponseBase`](#ApiResponseBase).[`links`](ApiResponseBase.md#links)
|
|
1197
|
-
|
|
1198
|
-
***
|
|
1199
|
-
|
|
1200
|
-
### meta?
|
|
1201
|
-
|
|
1202
|
-
```ts
|
|
1203
|
-
optional meta: Record<string, unknown>;
|
|
1204
|
-
```
|
|
1205
|
-
|
|
1206
|
-
### Inherited from
|
|
1207
|
-
|
|
1208
|
-
[`ApiResponseBase`](#ApiResponseBase).[`meta`](ApiResponseBase.md#meta)
|
|
1209
|
-
|
|
1210
|
-
***
|
|
1211
|
-
|
|
1212
|
-
### data
|
|
1213
|
-
|
|
1214
|
-
```ts
|
|
1215
|
-
data: T;
|
|
1216
|
-
```
|
|
1217
|
-
|
|
1218
|
-
***
|
|
1219
|
-
|
|
1220
|
-
### included?
|
|
1221
|
-
|
|
1222
|
-
```ts
|
|
1223
|
-
optional included: ApiResourceObject[];
|
|
1224
|
-
```
|
|
965
|
+
| Property | Type | Inherited from |
|
|
966
|
+
| ------ | ------ | ------ |
|
|
967
|
+
| <a id="jsonapi"></a> `jsonapi?` | [`JsonApi`](#JsonApi) | [`ApiResponseBase`](#ApiResponseBase).[`jsonapi`](ApiResponseBase.md#jsonapi) |
|
|
968
|
+
| <a id="links"></a> `links?` | [`ApiLinks`](#../type-aliases/ApiLinks) | [`ApiResponseBase`](#ApiResponseBase).[`links`](ApiResponseBase.md#links) |
|
|
969
|
+
| <a id="meta"></a> `meta?` | `Record`\<`string`, `unknown`\> | [`ApiResponseBase`](#ApiResponseBase).[`meta`](ApiResponseBase.md#meta) |
|
|
970
|
+
| <a id="data"></a> `data` | `T` | - |
|
|
971
|
+
| <a id="included"></a> `included?` | [`ApiResourceObject`](#ApiResourceObject)[] | - |
|
|
1225
972
|
|
|
1226
973
|
### <a id="ApiError"></a>ApiError
|
|
1227
974
|
|
|
@@ -1231,84 +978,16 @@ optional included: ApiResourceObject[];
|
|
|
1231
978
|
|
|
1232
979
|
## Properties
|
|
1233
980
|
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
### detail?
|
|
1245
|
-
|
|
1246
|
-
```ts
|
|
1247
|
-
optional detail: string;
|
|
1248
|
-
```
|
|
1249
|
-
|
|
1250
|
-
A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized.
|
|
1251
|
-
|
|
1252
|
-
***
|
|
1253
|
-
|
|
1254
|
-
### id?
|
|
1255
|
-
|
|
1256
|
-
```ts
|
|
1257
|
-
optional id: string;
|
|
1258
|
-
```
|
|
1259
|
-
|
|
1260
|
-
A unique identifier for this particular occurrence of the problem.
|
|
1261
|
-
|
|
1262
|
-
***
|
|
1263
|
-
|
|
1264
|
-
### links?
|
|
1265
|
-
|
|
1266
|
-
```ts
|
|
1267
|
-
optional links: ApiLinks;
|
|
1268
|
-
```
|
|
1269
|
-
|
|
1270
|
-
A links object containing the following members:
|
|
1271
|
-
about: a link that leads to further details about this particular occurrence of the problem
|
|
1272
|
-
|
|
1273
|
-
***
|
|
1274
|
-
|
|
1275
|
-
### meta?
|
|
1276
|
-
|
|
1277
|
-
```ts
|
|
1278
|
-
optional meta: Record<string, unknown>;
|
|
1279
|
-
```
|
|
1280
|
-
|
|
1281
|
-
A meta object containing non-standard meta-information about the error.
|
|
1282
|
-
|
|
1283
|
-
***
|
|
1284
|
-
|
|
1285
|
-
### source?
|
|
1286
|
-
|
|
1287
|
-
```ts
|
|
1288
|
-
optional source: Source;
|
|
1289
|
-
```
|
|
1290
|
-
|
|
1291
|
-
An object containing references to the source of the error, optionally including any of the following members:
|
|
1292
|
-
|
|
1293
|
-
***
|
|
1294
|
-
|
|
1295
|
-
### status?
|
|
1296
|
-
|
|
1297
|
-
```ts
|
|
1298
|
-
optional status: string;
|
|
1299
|
-
```
|
|
1300
|
-
|
|
1301
|
-
The HTTP status code applicable to this problem, expressed as a string value.
|
|
1302
|
-
|
|
1303
|
-
***
|
|
1304
|
-
|
|
1305
|
-
### title?
|
|
1306
|
-
|
|
1307
|
-
```ts
|
|
1308
|
-
optional title: string;
|
|
1309
|
-
```
|
|
1310
|
-
|
|
1311
|
-
A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.
|
|
981
|
+
| Property | Type | Description |
|
|
982
|
+
| ------ | ------ | ------ |
|
|
983
|
+
| <a id="code"></a> `code?` | `string` | An application-specific error code, expressed as a string value. |
|
|
984
|
+
| <a id="detail"></a> `detail?` | `string` | A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized. |
|
|
985
|
+
| <a id="id"></a> `id?` | `string` | A unique identifier for this particular occurrence of the problem. |
|
|
986
|
+
| <a id="links"></a> `links?` | [`ApiLinks`](#../type-aliases/ApiLinks) | A links object containing the following members: about: a link that leads to further details about this particular occurrence of the problem |
|
|
987
|
+
| <a id="meta"></a> `meta?` | `Record`\<`string`, `unknown`\> | A meta object containing non-standard meta-information about the error. |
|
|
988
|
+
| <a id="source"></a> `source?` | [`Source`](#Source) | An object containing references to the source of the error, optionally including any of the following members: |
|
|
989
|
+
| <a id="status"></a> `status?` | `string` | The HTTP status code applicable to this problem, expressed as a string value. |
|
|
990
|
+
| <a id="title"></a> `title?` | `string` | A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization. |
|
|
1312
991
|
|
|
1313
992
|
### <a id="ApiErrorResponse"></a>ApiErrorResponse
|
|
1314
993
|
|
|
@@ -1324,47 +1003,12 @@ A JSON:API error response containing one or more error objects.
|
|
|
1324
1003
|
|
|
1325
1004
|
## Properties
|
|
1326
1005
|
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
### Inherited from
|
|
1334
|
-
|
|
1335
|
-
[`ApiResponseBase`](#ApiResponseBase).[`jsonapi`](ApiResponseBase.md#jsonapi)
|
|
1336
|
-
|
|
1337
|
-
***
|
|
1338
|
-
|
|
1339
|
-
### links?
|
|
1340
|
-
|
|
1341
|
-
```ts
|
|
1342
|
-
optional links: ApiLinks;
|
|
1343
|
-
```
|
|
1344
|
-
|
|
1345
|
-
### Inherited from
|
|
1346
|
-
|
|
1347
|
-
[`ApiResponseBase`](#ApiResponseBase).[`links`](ApiResponseBase.md#links)
|
|
1348
|
-
|
|
1349
|
-
***
|
|
1350
|
-
|
|
1351
|
-
### meta?
|
|
1352
|
-
|
|
1353
|
-
```ts
|
|
1354
|
-
optional meta: Record<string, unknown>;
|
|
1355
|
-
```
|
|
1356
|
-
|
|
1357
|
-
### Inherited from
|
|
1358
|
-
|
|
1359
|
-
[`ApiResponseBase`](#ApiResponseBase).[`meta`](ApiResponseBase.md#meta)
|
|
1360
|
-
|
|
1361
|
-
***
|
|
1362
|
-
|
|
1363
|
-
### errors
|
|
1364
|
-
|
|
1365
|
-
```ts
|
|
1366
|
-
errors: ApiError[];
|
|
1367
|
-
```
|
|
1006
|
+
| Property | Type | Inherited from |
|
|
1007
|
+
| ------ | ------ | ------ |
|
|
1008
|
+
| <a id="jsonapi"></a> `jsonapi?` | [`JsonApi`](#JsonApi) | [`ApiResponseBase`](#ApiResponseBase).[`jsonapi`](ApiResponseBase.md#jsonapi) |
|
|
1009
|
+
| <a id="links"></a> `links?` | [`ApiLinks`](#../type-aliases/ApiLinks) | [`ApiResponseBase`](#ApiResponseBase).[`links`](ApiResponseBase.md#links) |
|
|
1010
|
+
| <a id="meta"></a> `meta?` | `Record`\<`string`, `unknown`\> | [`ApiResponseBase`](#ApiResponseBase).[`meta`](ApiResponseBase.md#meta) |
|
|
1011
|
+
| <a id="errors"></a> `errors` | [`ApiError`](#ApiError)[] | - |
|
|
1368
1012
|
|
|
1369
1013
|
### <a id="ApiResourceIdentifierObject"></a>ApiResourceIdentifierObject
|
|
1370
1014
|
|
|
@@ -1381,24 +1025,10 @@ Within a given API, each resource object's type and id pair MUST identify a sing
|
|
|
1381
1025
|
|
|
1382
1026
|
## Properties
|
|
1383
1027
|
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
id
|
|
1388
|
-
```
|
|
1389
|
-
|
|
1390
|
-
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.
|
|
1391
|
-
|
|
1392
|
-
***
|
|
1393
|
-
|
|
1394
|
-
### type
|
|
1395
|
-
|
|
1396
|
-
```ts
|
|
1397
|
-
type: string;
|
|
1398
|
-
```
|
|
1399
|
-
|
|
1400
|
-
The type member is used to describe resource objects that share common attributes and relationships.
|
|
1401
|
-
The values of type members MUST adhere to the same constraints as member names.
|
|
1028
|
+
| Property | Type | Description |
|
|
1029
|
+
| ------ | ------ | ------ |
|
|
1030
|
+
| <a id="id"></a> `id` | `string` | 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. |
|
|
1031
|
+
| <a id="type"></a> `type` | `string` | The type member is used to describe resource objects that share common attributes and relationships. The values of type members MUST adhere to the same constraints as member names. |
|
|
1402
1032
|
|
|
1403
1033
|
### <a id="ApiResourceObject"></a>ApiResourceObject
|
|
1404
1034
|
|
|
@@ -1414,72 +1044,14 @@ A JSON:API resource object with optional attributes, links, meta, and relationsh
|
|
|
1414
1044
|
|
|
1415
1045
|
## Properties
|
|
1416
1046
|
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
id
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
### Inherited from
|
|
1426
|
-
|
|
1427
|
-
[`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject).[`id`](ApiResourceIdentifierObject.md#id)
|
|
1428
|
-
|
|
1429
|
-
***
|
|
1430
|
-
|
|
1431
|
-
### type
|
|
1432
|
-
|
|
1433
|
-
```ts
|
|
1434
|
-
type: string;
|
|
1435
|
-
```
|
|
1436
|
-
|
|
1437
|
-
The type member is used to describe resource objects that share common attributes and relationships.
|
|
1438
|
-
The values of type members MUST adhere to the same constraints as member names.
|
|
1439
|
-
|
|
1440
|
-
### Inherited from
|
|
1441
|
-
|
|
1442
|
-
[`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject).[`type`](ApiResourceIdentifierObject.md#type)
|
|
1443
|
-
|
|
1444
|
-
***
|
|
1445
|
-
|
|
1446
|
-
### attributes?
|
|
1447
|
-
|
|
1448
|
-
```ts
|
|
1449
|
-
optional attributes: Record<string, unknown>;
|
|
1450
|
-
```
|
|
1451
|
-
|
|
1452
|
-
An attributes object representing some of the resource's data.
|
|
1453
|
-
|
|
1454
|
-
***
|
|
1455
|
-
|
|
1456
|
-
### links?
|
|
1457
|
-
|
|
1458
|
-
```ts
|
|
1459
|
-
optional links: ApiLinks;
|
|
1460
|
-
```
|
|
1461
|
-
|
|
1462
|
-
A links object containing links related to the resource.
|
|
1463
|
-
|
|
1464
|
-
***
|
|
1465
|
-
|
|
1466
|
-
### meta?
|
|
1467
|
-
|
|
1468
|
-
```ts
|
|
1469
|
-
optional meta: Record<string, unknown>;
|
|
1470
|
-
```
|
|
1471
|
-
|
|
1472
|
-
A meta object containing non-standard meta-information about a resource that can not be represented as an attribute or relationship.
|
|
1473
|
-
|
|
1474
|
-
***
|
|
1475
|
-
|
|
1476
|
-
### relationships?
|
|
1477
|
-
|
|
1478
|
-
```ts
|
|
1479
|
-
optional relationships: Record<string, Relationship>;
|
|
1480
|
-
```
|
|
1481
|
-
|
|
1482
|
-
A relationships object describing relationships between the resource and other JSON:API resources.
|
|
1047
|
+
| Property | Type | Description | Inherited from |
|
|
1048
|
+
| ------ | ------ | ------ | ------ |
|
|
1049
|
+
| <a id="id"></a> `id` | `string` | 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. | [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject).[`id`](ApiResourceIdentifierObject.md#id) |
|
|
1050
|
+
| <a id="type"></a> `type` | `string` | The type member is used to describe resource objects that share common attributes and relationships. The values of type members MUST adhere to the same constraints as member names. | [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject).[`type`](ApiResourceIdentifierObject.md#type) |
|
|
1051
|
+
| <a id="attributes"></a> `attributes?` | `Record`\<`string`, `unknown`\> | An attributes object representing some of the resource's data. | - |
|
|
1052
|
+
| <a id="links"></a> `links?` | [`ApiLinks`](#../type-aliases/ApiLinks) | A links object containing links related to the resource. | - |
|
|
1053
|
+
| <a id="meta"></a> `meta?` | `Record`\<`string`, `unknown`\> | A meta object containing non-standard meta-information about a resource that can not be represented as an attribute or relationship. | - |
|
|
1054
|
+
| <a id="relationships"></a> `relationships?` | `Record`\<`string`, [`Relationship`](#../type-aliases/Relationship)\> | A relationships object describing relationships between the resource and other JSON:API resources. | - |
|
|
1483
1055
|
|
|
1484
1056
|
### <a id="ApiResponseBase"></a>ApiResponseBase
|
|
1485
1057
|
|
|
@@ -1496,27 +1068,11 @@ Base interface for all JSON:API responses, including optional links and metadata
|
|
|
1496
1068
|
|
|
1497
1069
|
## Properties
|
|
1498
1070
|
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
***
|
|
1506
|
-
|
|
1507
|
-
### links?
|
|
1508
|
-
|
|
1509
|
-
```ts
|
|
1510
|
-
optional links: ApiLinks;
|
|
1511
|
-
```
|
|
1512
|
-
|
|
1513
|
-
***
|
|
1514
|
-
|
|
1515
|
-
### meta?
|
|
1516
|
-
|
|
1517
|
-
```ts
|
|
1518
|
-
optional meta: Record<string, unknown>;
|
|
1519
|
-
```
|
|
1071
|
+
| Property | Type |
|
|
1072
|
+
| ------ | ------ |
|
|
1073
|
+
| <a id="jsonapi"></a> `jsonapi?` | [`JsonApi`](#JsonApi) |
|
|
1074
|
+
| <a id="links"></a> `links?` | [`ApiLinks`](#../type-aliases/ApiLinks) |
|
|
1075
|
+
| <a id="meta"></a> `meta?` | `Record`\<`string`, `unknown`\> |
|
|
1520
1076
|
|
|
1521
1077
|
### <a id="Empty"></a>Empty
|
|
1522
1078
|
|
|
@@ -1540,11 +1096,9 @@ An Error with an optional HTTP status code for Express error handling.
|
|
|
1540
1096
|
|
|
1541
1097
|
## Properties
|
|
1542
1098
|
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
optional statusCode: number;
|
|
1547
|
-
```
|
|
1099
|
+
| Property | Type |
|
|
1100
|
+
| ------ | ------ |
|
|
1101
|
+
| <a id="statuscode"></a> `statusCode?` | `number` |
|
|
1548
1102
|
|
|
1549
1103
|
### <a id="HrefWithMeta"></a>HrefWithMeta
|
|
1550
1104
|
|
|
@@ -1556,19 +1110,10 @@ A link with an href and associated metadata.
|
|
|
1556
1110
|
|
|
1557
1111
|
## Properties
|
|
1558
1112
|
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
```
|
|
1564
|
-
|
|
1565
|
-
***
|
|
1566
|
-
|
|
1567
|
-
### meta
|
|
1568
|
-
|
|
1569
|
-
```ts
|
|
1570
|
-
meta: Record<string, unknown>;
|
|
1571
|
-
```
|
|
1113
|
+
| Property | Type |
|
|
1114
|
+
| ------ | ------ |
|
|
1115
|
+
| <a id="href"></a> `href` | `string` |
|
|
1116
|
+
| <a id="meta"></a> `meta` | `Record`\<`string`, `unknown`\> |
|
|
1572
1117
|
|
|
1573
1118
|
### <a id="IRelationshipData"></a>IRelationshipData
|
|
1574
1119
|
|
|
@@ -1580,11 +1125,9 @@ Contains the resource linkage data for a JSON:API relationship.
|
|
|
1580
1125
|
|
|
1581
1126
|
## Properties
|
|
1582
1127
|
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
data: ResourceLinkage;
|
|
1587
|
-
```
|
|
1128
|
+
| Property | Type |
|
|
1129
|
+
| ------ | ------ |
|
|
1130
|
+
| <a id="data"></a> `data` | [`ResourceLinkage`](#../type-aliases/ResourceLinkage) |
|
|
1588
1131
|
|
|
1589
1132
|
### <a id="IRelationshipLinks"></a>IRelationshipLinks
|
|
1590
1133
|
|
|
@@ -1596,13 +1139,9 @@ Contains the links for a JSON:API relationship.
|
|
|
1596
1139
|
|
|
1597
1140
|
## Properties
|
|
1598
1141
|
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
links:
|
|
1603
|
-
| IRelationshipSelfLink
|
|
1604
|
-
| IRelationshipRelatedLink;
|
|
1605
|
-
```
|
|
1142
|
+
| Property | Type |
|
|
1143
|
+
| ------ | ------ |
|
|
1144
|
+
| <a id="links"></a> `links` | \| [`IRelationshipSelfLink`](#IRelationshipSelfLink) \| [`IRelationshipRelatedLink`](#IRelationshipRelatedLink) |
|
|
1606
1145
|
|
|
1607
1146
|
### <a id="IRelationshipRelatedLink"></a>IRelationshipRelatedLink
|
|
1608
1147
|
|
|
@@ -1614,13 +1153,9 @@ A relationship link pointing to a related resource.
|
|
|
1614
1153
|
|
|
1615
1154
|
## Properties
|
|
1616
1155
|
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
related: string;
|
|
1621
|
-
```
|
|
1622
|
-
|
|
1623
|
-
A related resource link
|
|
1156
|
+
| Property | Type | Description |
|
|
1157
|
+
| ------ | ------ | ------ |
|
|
1158
|
+
| <a id="related"></a> `related` | `string` | A related resource link |
|
|
1624
1159
|
|
|
1625
1160
|
### <a id="IRelationshipSelfLink"></a>IRelationshipSelfLink
|
|
1626
1161
|
|
|
@@ -1632,15 +1167,9 @@ A relationship link pointing to the relationship itself.
|
|
|
1632
1167
|
|
|
1633
1168
|
## Properties
|
|
1634
1169
|
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
self: string;
|
|
1639
|
-
```
|
|
1640
|
-
|
|
1641
|
-
A link for the relationship itself (a "relationship link"). This link allows the client to directly manipulate the relationship.
|
|
1642
|
-
For example, removing an author through an article’s relationship URL would disconnect the person from the article without
|
|
1643
|
-
deleting the people resource itself. When fetched successfully, this link returns the linkage for the related resources as its primary data.
|
|
1170
|
+
| Property | Type | Description |
|
|
1171
|
+
| ------ | ------ | ------ |
|
|
1172
|
+
| <a id="self"></a> `self` | `string` | A link for the relationship itself (a "relationship link"). This link allows the client to directly manipulate the relationship. For example, removing an author through an article’s relationship URL would disconnect the person from the article without deleting the people resource itself. When fetched successfully, this link returns the linkage for the related resources as its primary data. |
|
|
1644
1173
|
|
|
1645
1174
|
### <a id="JsonApi"></a>JsonApi
|
|
1646
1175
|
|
|
@@ -1652,19 +1181,10 @@ JSON:API version and metadata descriptor.
|
|
|
1652
1181
|
|
|
1653
1182
|
## Properties
|
|
1654
1183
|
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
```
|
|
1660
|
-
|
|
1661
|
-
***
|
|
1662
|
-
|
|
1663
|
-
### version?
|
|
1664
|
-
|
|
1665
|
-
```ts
|
|
1666
|
-
optional version: "1.0" | "1.1";
|
|
1667
|
-
```
|
|
1184
|
+
| Property | Type |
|
|
1185
|
+
| ------ | ------ |
|
|
1186
|
+
| <a id="meta"></a> `meta?` | `Record`\<`string`, `unknown`\> |
|
|
1187
|
+
| <a id="version"></a> `version?` | `"1.0"` \| `"1.1"` |
|
|
1668
1188
|
|
|
1669
1189
|
### <a id="LoggerOptions"></a>LoggerOptions
|
|
1670
1190
|
|
|
@@ -1676,19 +1196,10 @@ Configuration options for creating a logger instance.
|
|
|
1676
1196
|
|
|
1677
1197
|
## Properties
|
|
1678
1198
|
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
```
|
|
1684
|
-
|
|
1685
|
-
***
|
|
1686
|
-
|
|
1687
|
-
### level?
|
|
1688
|
-
|
|
1689
|
-
```ts
|
|
1690
|
-
optional level: LoggerVerbosity;
|
|
1691
|
-
```
|
|
1199
|
+
| Property | Type |
|
|
1200
|
+
| ------ | ------ |
|
|
1201
|
+
| <a id="defaultmeta"></a> `defaultMeta?` | [`LoggerMeta`](#../type-aliases/LoggerMeta) |
|
|
1202
|
+
| <a id="level"></a> `level?` | [`LoggerVerbosity`](#../type-aliases/LoggerVerbosity) |
|
|
1692
1203
|
|
|
1693
1204
|
### <a id="RouteDefinition"></a>RouteDefinition
|
|
1694
1205
|
|
|
@@ -1700,33 +1211,17 @@ Defines an Express route with its HTTP method, path, and handler(s).
|
|
|
1700
1211
|
|
|
1701
1212
|
## Type Parameters
|
|
1702
1213
|
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
`H` *extends* `RequestHandler`
|
|
1214
|
+
| Type Parameter | Default type |
|
|
1215
|
+
| ------ | ------ |
|
|
1216
|
+
| `H` *extends* `RequestHandler` | `RequestHandler` |
|
|
1706
1217
|
|
|
1707
1218
|
## Properties
|
|
1708
1219
|
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
***
|
|
1716
|
-
|
|
1717
|
-
### method
|
|
1718
|
-
|
|
1719
|
-
```ts
|
|
1720
|
-
method: HttpMethod;
|
|
1721
|
-
```
|
|
1722
|
-
|
|
1723
|
-
***
|
|
1724
|
-
|
|
1725
|
-
### path
|
|
1726
|
-
|
|
1727
|
-
```ts
|
|
1728
|
-
path: string | RegExp;
|
|
1729
|
-
```
|
|
1220
|
+
| Property | Type |
|
|
1221
|
+
| ------ | ------ |
|
|
1222
|
+
| <a id="handlers"></a> `handlers` | `H` \| `H`[] |
|
|
1223
|
+
| <a id="method"></a> `method` | [`HttpMethod`](#../type-aliases/HttpMethod) |
|
|
1224
|
+
| <a id="path"></a> `path` | `string` \| `RegExp` |
|
|
1730
1225
|
|
|
1731
1226
|
### <a id="Source"></a>Source
|
|
1732
1227
|
|
|
@@ -1738,24 +1233,10 @@ An object containing references to the source of the error
|
|
|
1738
1233
|
|
|
1739
1234
|
## Properties
|
|
1740
1235
|
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
```
|
|
1746
|
-
|
|
1747
|
-
A string indicating which URI query parameter caused the error.
|
|
1748
|
-
|
|
1749
|
-
***
|
|
1750
|
-
|
|
1751
|
-
### pointer?
|
|
1752
|
-
|
|
1753
|
-
```ts
|
|
1754
|
-
optional pointer: string;
|
|
1755
|
-
```
|
|
1756
|
-
|
|
1757
|
-
A JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object,
|
|
1758
|
-
or "/data/attributes/title" for a specific attribute].
|
|
1236
|
+
| Property | Type | Description |
|
|
1237
|
+
| ------ | ------ | ------ |
|
|
1238
|
+
| <a id="parameter"></a> `parameter?` | `string` | A string indicating which URI query parameter caused the error. |
|
|
1239
|
+
| <a id="pointer"></a> `pointer?` | `string` | A JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object, or "/data/attributes/title" for a specific attribute]. |
|
|
1759
1240
|
|
|
1760
1241
|
### type-aliases
|
|
1761
1242
|
|
|
@@ -1799,9 +1280,9 @@ A JSON:API response, either a data response or an error response.
|
|
|
1799
1280
|
|
|
1800
1281
|
## Type Parameters
|
|
1801
1282
|
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
`T` *extends* [`ApiResourceIdentifierObject`](#../interfaces/ApiResourceIdentifierObject)
|
|
1283
|
+
| Type Parameter |
|
|
1284
|
+
| ------ |
|
|
1285
|
+
| `T` *extends* [`ApiResourceIdentifierObject`](#../interfaces/ApiResourceIdentifierObject) |
|
|
1805
1286
|
|
|
1806
1287
|
### <a id="HttpMethod"></a>HttpMethod
|
|
1807
1288
|
|
|
@@ -1934,22 +1415,22 @@ Default type for response body when none is specified.
|
|
|
1934
1415
|
***
|
|
1935
1416
|
|
|
1936
1417
|
```ts
|
|
1937
|
-
type ParseFunc<T> = (value) => T;
|
|
1418
|
+
type ParseFunc<T> = (value: string) => T;
|
|
1938
1419
|
```
|
|
1939
1420
|
|
|
1940
1421
|
A function that parses a string value into the target type.
|
|
1941
1422
|
|
|
1942
1423
|
## Type Parameters
|
|
1943
1424
|
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
`T`
|
|
1425
|
+
| Type Parameter | Default type |
|
|
1426
|
+
| ------ | ------ |
|
|
1427
|
+
| `T` | `number` |
|
|
1947
1428
|
|
|
1948
1429
|
## Parameters
|
|
1949
1430
|
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
`string`
|
|
1431
|
+
| Parameter | Type |
|
|
1432
|
+
| ------ | ------ |
|
|
1433
|
+
| `value` | `string` |
|
|
1953
1434
|
|
|
1954
1435
|
## Returns
|
|
1955
1436
|
|
|
@@ -2076,38 +1557,26 @@ Empty Zod schema for requests with no query parameters.
|
|
|
2076
1557
|
***
|
|
2077
1558
|
|
|
2078
1559
|
```ts
|
|
2079
|
-
const ValidateRequestDefaults:
|
|
1560
|
+
const ValidateRequestDefaults: {
|
|
1561
|
+
params: ZodObject<{
|
|
1562
|
+
}, $catchall<ZodString>>;
|
|
1563
|
+
query: ZodObject<{
|
|
1564
|
+
}, $catchall<ZodUnion<readonly [ZodString, ZodArray<ZodString>]>>>;
|
|
1565
|
+
body: ZodOptional<ZodJSONSchema>;
|
|
1566
|
+
response: ZodOptional<ZodJSONSchema>;
|
|
1567
|
+
};
|
|
2080
1568
|
```
|
|
2081
1569
|
|
|
2082
1570
|
Default validation schemas for request handler validator.
|
|
2083
1571
|
|
|
2084
1572
|
## Type Declaration
|
|
2085
1573
|
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
### query
|
|
2094
|
-
|
|
2095
|
-
```ts
|
|
2096
|
-
query: ZodObject<{
|
|
2097
|
-
}, $catchall<ZodUnion<readonly [ZodString, ZodArray<ZodString>]>>> = EmptyQueryParamsZod;
|
|
2098
|
-
```
|
|
2099
|
-
|
|
2100
|
-
### body
|
|
2101
|
-
|
|
2102
|
-
```ts
|
|
2103
|
-
body: ZodOptional<ZodJSONSchema>;
|
|
2104
|
-
```
|
|
2105
|
-
|
|
2106
|
-
### response
|
|
2107
|
-
|
|
2108
|
-
```ts
|
|
2109
|
-
response: ZodOptional<ZodJSONSchema>;
|
|
2110
|
-
```
|
|
1574
|
+
| Name | Type | Default value |
|
|
1575
|
+
| ------ | ------ | ------ |
|
|
1576
|
+
| <a id="property-params"></a> `params` | `ZodObject`\<\{ \}, `$catchall`\<`ZodString`\>\> | `EmptyParamsZod` |
|
|
1577
|
+
| <a id="property-query"></a> `query` | `ZodObject`\<\{ \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> | `EmptyQueryParamsZod` |
|
|
1578
|
+
| <a id="property-body"></a> `body` | `ZodOptional`\<`ZodJSONSchema`\> | - |
|
|
1579
|
+
| <a id="property-response"></a> `response` | `ZodOptional`\<`ZodJSONSchema`\> | - |
|
|
2111
1580
|
|
|
2112
1581
|
### <a id="jsonBodyParser"></a>jsonBodyParser
|
|
2113
1582
|
|