expediate 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +138 -0
- package/CONTRIBUTING.md +150 -0
- package/LICENSE +16 -16
- package/README.md +330 -444
- package/dist/apis.d.ts +504 -27
- package/dist/apis.d.ts.map +1 -1
- package/dist/apis.js +618 -107
- package/dist/apis.js.map +1 -1
- package/dist/cjs/index.js +4066 -0
- package/dist/cjs/package.json +1 -0
- package/dist/git.d.ts +72 -9
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +129 -74
- package/dist/git.js.map +1 -1
- package/dist/http-objects.d.ts +26 -0
- package/dist/http-objects.d.ts.map +1 -0
- package/dist/http-objects.js +588 -0
- package/dist/http-objects.js.map +1 -0
- package/dist/index.d.ts +18 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -24
- package/dist/index.js.map +1 -1
- package/dist/jwt-auth.d.ts +158 -57
- package/dist/jwt-auth.d.ts.map +1 -1
- package/dist/jwt-auth.js +447 -207
- package/dist/jwt-auth.js.map +1 -1
- package/dist/middleware.d.ts +476 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +647 -0
- package/dist/middleware.js.map +1 -0
- package/dist/mimetypes.json +882 -1
- package/dist/misc.d.ts +268 -25
- package/dist/misc.d.ts.map +1 -1
- package/dist/misc.js +449 -168
- package/dist/misc.js.map +1 -1
- package/dist/openapi.d.ts +433 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/openapi.js +624 -0
- package/dist/openapi.js.map +1 -0
- package/dist/router-types.d.ts +760 -0
- package/dist/router-types.d.ts.map +1 -0
- package/dist/router-types.js +23 -0
- package/dist/router-types.js.map +1 -0
- package/dist/router.d.ts +37 -201
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +502 -244
- package/dist/router.js.map +1 -1
- package/dist/static.d.ts +3 -3
- package/dist/static.d.ts.map +1 -1
- package/dist/static.js +164 -105
- package/dist/static.js.map +1 -1
- package/docs/THREAT_MODEL.md +52 -0
- package/docs/api-builder-v2-design.md +644 -0
- package/docs/api-builder-v3-design.md +397 -0
- package/docs/api-builder.md +454 -0
- package/docs/benchmark.md +27 -0
- package/docs/body-parsing.md +223 -0
- package/docs/errors.md +359 -0
- package/docs/expediate.png +0 -0
- package/docs/git.md +139 -0
- package/docs/jwt-auth.md +251 -0
- package/docs/logo.svg +12 -0
- package/docs/middleware.md +264 -0
- package/docs/openapi.md +180 -0
- package/docs/router.md +356 -0
- package/docs/static.md +128 -0
- package/docs/wiki.json +123 -0
- package/package.json +47 -8
- package/.npmignore +0 -16
package/dist/misc.d.ts
CHANGED
|
@@ -1,13 +1,42 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Readable } from 'stream';
|
|
2
|
+
import type { RouterRequest, RouterResponse, Middleware } from './router.js';
|
|
2
3
|
/**
|
|
3
4
|
* A JSON reviver function, matching the second parameter of `JSON.parse`.
|
|
4
5
|
* Receives each key/value pair during parsing and may return a transformed
|
|
5
6
|
* value.
|
|
6
7
|
*/
|
|
7
8
|
type Reviver = (key: string, value: unknown) => unknown;
|
|
9
|
+
/**
|
|
10
|
+
* Selects which requests a body parser handles, based on `Content-Type`.
|
|
11
|
+
*
|
|
12
|
+
* - **string** — a MIME type, matched against the request's media type.
|
|
13
|
+
* Wildcards are supported: `'*\/*'` matches anything and `'application/*'`
|
|
14
|
+
* matches any `application/…` subtype.
|
|
15
|
+
* - **string[]** — matches when any entry matches.
|
|
16
|
+
* - **function** — a predicate receiving the request; return `true` to handle it.
|
|
17
|
+
*
|
|
18
|
+
* Matching is case-insensitive. Requests that do not match are passed through
|
|
19
|
+
* to the next middleware untouched.
|
|
20
|
+
*/
|
|
21
|
+
export type BodyTypeMatcher = string | string[] | ((req: RouterRequest) => boolean);
|
|
22
|
+
/**
|
|
23
|
+
* Hook invoked with the raw (already decompressed) body buffer **before** it is
|
|
24
|
+
* parsed. Mirrors Express's `verify` option and is typically used to capture
|
|
25
|
+
* the raw bytes (e.g. for webhook signature verification).
|
|
26
|
+
*
|
|
27
|
+
* Throw to reject the request: the thrown value's `status`/`statusCode` is used
|
|
28
|
+
* as the HTTP status (defaulting to `403`), and its `message` as the body.
|
|
29
|
+
*
|
|
30
|
+
* @param req - The incoming request.
|
|
31
|
+
* @param res - The outgoing response.
|
|
32
|
+
* @param buf - The raw, decompressed body buffer.
|
|
33
|
+
* @param encoding - The charset parsed from the `Content-Type` header.
|
|
34
|
+
*/
|
|
35
|
+
export type VerifyFn = (req: RouterRequest, res: RouterResponse, buf: Buffer, encoding: string) => void;
|
|
8
36
|
/**
|
|
9
37
|
* Options shared by all body-parsing middleware factories
|
|
10
|
-
* ({@link json}, {@link formData}, {@link
|
|
38
|
+
* ({@link json}, {@link formData}, {@link formEncoded}, {@link raw},
|
|
39
|
+
* {@link text}, {@link parseBody}).
|
|
11
40
|
*/
|
|
12
41
|
export interface BodyOptions {
|
|
13
42
|
/**
|
|
@@ -30,15 +59,32 @@ export interface BodyOptions {
|
|
|
30
59
|
reviver?: Reviver | null;
|
|
31
60
|
/**
|
|
32
61
|
* When `true` (default), JSON parsing is restricted to objects and arrays.
|
|
33
|
-
* Bare primitives (strings, numbers, booleans) at the top level
|
|
34
|
-
* rejected
|
|
62
|
+
* Bare primitives (strings, numbers, booleans, or `null`) at the top level
|
|
63
|
+
* are rejected with `400 Bad Request`. Has no effect on non-JSON bodies.
|
|
35
64
|
*
|
|
36
|
-
* @remarks
|
|
65
|
+
* @remarks Enforced in `readBodyAsJson` (tagged `FIX-10`).
|
|
37
66
|
*/
|
|
38
67
|
strict?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Override which requests this parser handles, based on `Content-Type`.
|
|
70
|
+
* When omitted, each factory uses its natural default (e.g. {@link json}
|
|
71
|
+
* defaults to `'application/json'`). See {@link BodyTypeMatcher}.
|
|
72
|
+
*/
|
|
73
|
+
type?: BodyTypeMatcher;
|
|
74
|
+
/**
|
|
75
|
+
* Optional hook called with the raw body buffer before parsing.
|
|
76
|
+
* Throw to reject the request. See {@link VerifyFn}.
|
|
77
|
+
*/
|
|
78
|
+
verify?: VerifyFn | null;
|
|
39
79
|
}
|
|
40
|
-
/**
|
|
41
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Resolved body options with all fields guaranteed to be present.
|
|
82
|
+
* `type` may be `null` (match any content type, used by {@link parseBody}).
|
|
83
|
+
*/
|
|
84
|
+
type ResolvedBodyOptions = Required<Omit<BodyOptions, 'type' | 'verify'>> & {
|
|
85
|
+
type: BodyTypeMatcher | null;
|
|
86
|
+
verify: VerifyFn | null;
|
|
87
|
+
};
|
|
42
88
|
/**
|
|
43
89
|
* Options for the {@link logger} middleware factory.
|
|
44
90
|
*/
|
|
@@ -117,29 +163,65 @@ export interface FormPart {
|
|
|
117
163
|
* @returns A Node.js-compatible encoding name (e.g. `'utf8'`, `'iso-8859-1'`).
|
|
118
164
|
*/
|
|
119
165
|
export declare function extractCharset(contentType: string): string;
|
|
120
|
-
export
|
|
166
|
+
export interface BodyContent {
|
|
121
167
|
mimetype: string;
|
|
122
168
|
content: Buffer;
|
|
123
|
-
}
|
|
124
|
-
export declare function readReqBody(req: RouterRequest, opts: ResolvedBodyOptions, mimetype: string | null): Promise<BodyContent | null>;
|
|
169
|
+
}
|
|
125
170
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
171
|
+
* Promise-based body collector used by the `req.json()`, `req.text()`, and
|
|
172
|
+
* `req.formData()` request helpers.
|
|
128
173
|
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* res
|
|
174
|
+
* @param req - The incoming request.
|
|
175
|
+
* @param opts - Resolved body-parsing options.
|
|
176
|
+
* @param mimetype - Expected MIME type, or `null` to accept any content type.
|
|
177
|
+
* @param res - The outgoing response, required only so an `opts.verify`
|
|
178
|
+
* hook receives the Express-style `(req, res, buf, encoding)`
|
|
179
|
+
* arguments. When omitted, the verify hook is skipped.
|
|
180
|
+
* @returns The collected `{ mimetype, content }`, or `null` for an empty body.
|
|
181
|
+
* Rejects with `{ status, message }` on size, encoding, type, or
|
|
182
|
+
* verify-hook failures.
|
|
183
|
+
*/
|
|
184
|
+
export declare function readReqBody(req: RouterRequest, opts: ResolvedBodyOptions, mimetype: string | null, res?: RouterResponse): Promise<BodyContent | null>;
|
|
185
|
+
/**
|
|
186
|
+
* Parse a raw `multipart/form-data` body buffer into an array of
|
|
187
|
+
* {@link FormPart} objects.
|
|
188
|
+
*
|
|
189
|
+
* This is the shared parsing kernel used by both the {@link formData}
|
|
190
|
+
* middleware and the `req.formData()` extension method on the request object.
|
|
191
|
+
*
|
|
192
|
+
* **Multipart wire format recap:**
|
|
133
193
|
* ```
|
|
194
|
+
* --boundary\r\n
|
|
195
|
+
* Header: value\r\n
|
|
196
|
+
* \r\n
|
|
197
|
+
* <binary content>
|
|
198
|
+
* --boundary\r\n
|
|
199
|
+
* ...
|
|
200
|
+
* --boundary--\r\n
|
|
201
|
+
* ```
|
|
202
|
+
* The boundary string in `Content-Type` does **not** include the leading `--`;
|
|
203
|
+
* actual part delimiters on the wire are `\r\n--boundary`.
|
|
204
|
+
*
|
|
205
|
+
* @param contentType - The raw `Content-Type` header value (must include
|
|
206
|
+
* `boundary=<value>`).
|
|
207
|
+
* @param data - The fully-collected raw body buffer.
|
|
208
|
+
* @returns An array of parsed {@link FormPart} objects.
|
|
209
|
+
* @throws `{ status: 400, message }` when the `boundary` parameter is absent.
|
|
210
|
+
*/
|
|
211
|
+
export declare function parseMultipartBody(contentType: string, data: Buffer): FormPart[];
|
|
212
|
+
/**
|
|
213
|
+
* Middleware factory that parses an `application/json` request body and
|
|
214
|
+
* assigns the parsed value to `req.body`.
|
|
134
215
|
*
|
|
135
216
|
* Behaviour:
|
|
136
217
|
* - Requests without a body (`Content-Length: 0` or absent) are passed
|
|
137
218
|
* through to `next()` without touching `req.body`.
|
|
219
|
+
* - Requests whose `Content-Type` is not `application/json` are also passed
|
|
220
|
+
* through to `next()` unchanged, allowing other parsers to handle them
|
|
221
|
+
* (Express-compatible composable behaviour).
|
|
138
222
|
* - Bodies larger than `opts.limit` receive **413 Content Too Large**.
|
|
139
223
|
* - Bodies with an unsupported `Content-Encoding` receive
|
|
140
224
|
* **415 Unsupported Media Type**.
|
|
141
|
-
* - Bodies whose `Content-Type` is not `application/json` receive
|
|
142
|
-
* **415 Unsupported Media Type**.
|
|
143
225
|
* - Parse errors receive **500 Internal Server Error**.
|
|
144
226
|
*
|
|
145
227
|
* @param opts - Optional configuration (see {@link BodyOptions}).
|
|
@@ -165,23 +247,142 @@ export declare function json(opts?: BodyOptions): Middleware;
|
|
|
165
247
|
* @returns An Express-compatible middleware function.
|
|
166
248
|
*/
|
|
167
249
|
export declare function formData(opts?: BodyOptions): Middleware;
|
|
250
|
+
/**
|
|
251
|
+
* Middleware factory that parses an `application/x-www-form-urlencoded`
|
|
252
|
+
* request body and assigns the decoded fields to `req.body`.
|
|
253
|
+
*
|
|
254
|
+
* Repeated keys (e.g. `tags=a&tags=b`) produce an array value:
|
|
255
|
+
* `{ tags: ['a', 'b'] }`. Single-occurrence keys produce a plain string.
|
|
256
|
+
*
|
|
257
|
+
* Behaviour:
|
|
258
|
+
* - Requests without a body are passed through to `next()`.
|
|
259
|
+
* - Bodies larger than `opts.limit` receive **413 Content Too Large**.
|
|
260
|
+
* - Requests whose `Content-Type` is not `application/x-www-form-urlencoded`
|
|
261
|
+
* are passed through to `next()` unchanged (Express-compatible composable behaviour).
|
|
262
|
+
* - Parse errors receive **400 Bad Request**.
|
|
263
|
+
*
|
|
264
|
+
* @param opts - Optional configuration (see {@link BodyOptions}).
|
|
265
|
+
* @returns An Express-compatible middleware function.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* app.post('/form', formEncoded(), (req, res) => {
|
|
270
|
+
* const { username, tags } = req.body as any;
|
|
271
|
+
* res.json({ username, tags }); // tags may be string | string[]
|
|
272
|
+
* });
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
export declare function formEncoded(opts?: BodyOptions): Middleware;
|
|
168
276
|
/**
|
|
169
277
|
* Middleware factory that auto-detects the `Content-Type` of the request body
|
|
170
278
|
* and parses it using the appropriate parser.
|
|
171
279
|
*
|
|
172
280
|
* Supported MIME types:
|
|
173
|
-
* - `application/json`
|
|
174
|
-
* - `multipart/form-data`
|
|
175
|
-
* - `
|
|
281
|
+
* - `application/json` → parsed as JSON; result is a JS value.
|
|
282
|
+
* - `multipart/form-data` → parsed as multipart; result is `FormPart[]`.
|
|
283
|
+
* - `application/x-www-form-urlencoded` → decoded as key/value pairs; result is
|
|
284
|
+
* `Record<string, string | string[]>`.
|
|
285
|
+
* - `text/plain` → decoded as text; result is a string.
|
|
176
286
|
*
|
|
177
287
|
* Requests with an unsupported MIME type receive **415 Unsupported Media Type**.
|
|
178
|
-
* All other error conditions behave identically to {@link json}
|
|
179
|
-
* {@link
|
|
288
|
+
* All other error conditions behave identically to {@link json}, {@link formData},
|
|
289
|
+
* and {@link formEncoded}.
|
|
180
290
|
*
|
|
181
291
|
* @param opts - Optional configuration (see {@link BodyOptions}).
|
|
182
292
|
* @returns An Express-compatible middleware function.
|
|
183
293
|
*/
|
|
184
294
|
export declare function parseBody(opts?: BodyOptions): Middleware;
|
|
295
|
+
/**
|
|
296
|
+
* Middleware factory that collects the request body into a `Buffer` and assigns
|
|
297
|
+
* it to `req.body` without any parsing.
|
|
298
|
+
*
|
|
299
|
+
* Behaviour:
|
|
300
|
+
* - Defaults to handling `application/octet-stream`; override with `opts.type`
|
|
301
|
+
* (e.g. `raw({ type: '*\/*' })` to capture every body).
|
|
302
|
+
* - Requests without a body are passed through to `next()`.
|
|
303
|
+
* - Requests whose `Content-Type` does not match are passed through unchanged.
|
|
304
|
+
* - Bodies larger than `opts.limit` receive **413 Content Too Large**.
|
|
305
|
+
* - Bodies with an unsupported `Content-Encoding` receive
|
|
306
|
+
* **415 Unsupported Media Type**.
|
|
307
|
+
*
|
|
308
|
+
* @param opts - Optional configuration (see {@link BodyOptions}).
|
|
309
|
+
* @returns An Express-compatible middleware function.
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```ts
|
|
313
|
+
* app.post('/webhook', raw({ type: 'application/json' }), (req, res) => {
|
|
314
|
+
* const raw = req.body as Buffer; // untouched bytes
|
|
315
|
+
* res.send('ok');
|
|
316
|
+
* });
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
export declare function raw(opts?: BodyOptions): Middleware;
|
|
320
|
+
/**
|
|
321
|
+
* Middleware factory that decodes the request body as text (using the charset
|
|
322
|
+
* from the `Content-Type` header) and assigns the resulting string to
|
|
323
|
+
* `req.body`.
|
|
324
|
+
*
|
|
325
|
+
* Behaviour:
|
|
326
|
+
* - Defaults to handling `text/plain`; override with `opts.type`
|
|
327
|
+
* (e.g. `text({ type: 'text/*' })`).
|
|
328
|
+
* - Requests without a body are passed through to `next()`.
|
|
329
|
+
* - Requests whose `Content-Type` does not match are passed through unchanged.
|
|
330
|
+
* - Bodies larger than `opts.limit` receive **413 Content Too Large**.
|
|
331
|
+
* - Decoding errors receive **500 Internal Server Error**.
|
|
332
|
+
*
|
|
333
|
+
* @param opts - Optional configuration (see {@link BodyOptions}).
|
|
334
|
+
* @returns An Express-compatible middleware function.
|
|
335
|
+
*/
|
|
336
|
+
export declare function text(opts?: BodyOptions): Middleware;
|
|
337
|
+
/**
|
|
338
|
+
* A single part from a `multipart/form-data` body, with its content exposed
|
|
339
|
+
* as a Node.js `Readable` stream instead of a pre-collected `Buffer`.
|
|
340
|
+
*
|
|
341
|
+
* Yielded by {@link streamFormData}.
|
|
342
|
+
*/
|
|
343
|
+
export interface FormPartStream {
|
|
344
|
+
/**
|
|
345
|
+
* Raw part headers (e.g. `Content-Disposition`, `Content-Type`).
|
|
346
|
+
* Keys are lowercased; values are trimmed.
|
|
347
|
+
*/
|
|
348
|
+
headers: Record<string, string>;
|
|
349
|
+
/**
|
|
350
|
+
* Readable stream of the part's binary content. The stream yields the full
|
|
351
|
+
* part content as a single chunk and then ends.
|
|
352
|
+
*/
|
|
353
|
+
stream: Readable;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Async generator that yields each part of a `multipart/form-data` request
|
|
357
|
+
* body as a {@link FormPartStream} object.
|
|
358
|
+
*
|
|
359
|
+
* Unlike {@link formData} (which must be installed as middleware before a
|
|
360
|
+
* handler), `streamFormData` can be called directly inside any handler and
|
|
361
|
+
* returns an async iterable of parts:
|
|
362
|
+
*
|
|
363
|
+
* ```ts
|
|
364
|
+
* app.post('/upload', async (req, res) => {
|
|
365
|
+
* for await (const part of streamFormData(req)) {
|
|
366
|
+
* const name = part.headers['content-disposition'];
|
|
367
|
+
* const chunks: Buffer[] = [];
|
|
368
|
+
* for await (const chunk of part.stream) chunks.push(chunk);
|
|
369
|
+
* const content = Buffer.concat(chunks);
|
|
370
|
+
* // ... process content
|
|
371
|
+
* }
|
|
372
|
+
* res.send('ok');
|
|
373
|
+
* });
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* **Note:** the full request body is buffered before parts are yielded,
|
|
377
|
+
* because the multipart boundary must span the entire body. For very large
|
|
378
|
+
* uploads, prefer streaming directly from the raw request.
|
|
379
|
+
*
|
|
380
|
+
* @param req - The incoming request (must be a `multipart/form-data` request).
|
|
381
|
+
* @param opts - Optional configuration — only `limit` and `inflate` are used.
|
|
382
|
+
* @throws `{ status: 400, message }` when the `boundary` parameter is absent.
|
|
383
|
+
* @throws `{ status: 413, message }` when the body exceeds the size limit.
|
|
384
|
+
*/
|
|
385
|
+
export declare function streamFormData(req: RouterRequest, opts?: BodyOptions): AsyncGenerator<FormPartStream>;
|
|
185
386
|
/**
|
|
186
387
|
* Middleware factory that logs one line per completed HTTP request to the
|
|
187
388
|
* console (or a custom logger function).
|
|
@@ -215,7 +416,25 @@ export declare function parseBody(opts?: BodyOptions): Middleware;
|
|
|
215
416
|
* ```
|
|
216
417
|
*/
|
|
217
418
|
export declare function logger(opts?: Partial<LoggerOptions>): Middleware;
|
|
218
|
-
|
|
419
|
+
/**
|
|
420
|
+
* Configuration for the {@link cors} middleware factory.
|
|
421
|
+
*/
|
|
422
|
+
export interface CorsOptions {
|
|
423
|
+
/**
|
|
424
|
+
* Value(s) allowed for `Access-Control-Allow-Origin`.
|
|
425
|
+
*
|
|
426
|
+
* - A single `string` (including `'*'`) is sent as-is — there's only one
|
|
427
|
+
* possible value, so no per-request matching is needed.
|
|
428
|
+
* - A `string[]` is treated as an allow-list: the request's `Origin` header
|
|
429
|
+
* is compared against each entry, and only the matching entry is echoed
|
|
430
|
+
* back as the (single) header value. `res.setHeader()` does not join
|
|
431
|
+
* array values for this header — sending the array directly would make
|
|
432
|
+
* Node emit one `Access-Control-Allow-Origin` line per element, which
|
|
433
|
+
* violates the CORS spec (only one value is permitted there) and causes
|
|
434
|
+
* browsers to reject the response outright.
|
|
435
|
+
* - When the request's `Origin` is not in the array, no match is sent and
|
|
436
|
+
* `Access-Control-Allow-Origin` is omitted, so the browser denies access.
|
|
437
|
+
*/
|
|
219
438
|
origin: string | string[];
|
|
220
439
|
allowHeaders: string | string[];
|
|
221
440
|
allowMethods: string | string[];
|
|
@@ -224,14 +443,38 @@ export type CorsOptions = {
|
|
|
224
443
|
vary: string | string[] | undefined;
|
|
225
444
|
optionsStatus: number;
|
|
226
445
|
preflight: ((req: RouterRequest) => boolean) | undefined;
|
|
227
|
-
}
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Middleware factory that adds Cross-Origin Resource Sharing (CORS) response
|
|
449
|
+
* headers and answers `OPTIONS` preflight requests.
|
|
450
|
+
*
|
|
451
|
+
* CORS headers are only set when the request carries an `Origin` header
|
|
452
|
+
* (browser-only; server-to-server requests typically omit it). When
|
|
453
|
+
* {@link CorsOptions.origin} is an array, the request's `Origin` is matched
|
|
454
|
+
* against it via {@link resolveAllowOrigin} and only the matching value is
|
|
455
|
+
* echoed back — see that option's documentation for why a plain array cannot
|
|
456
|
+
* be passed straight to `res.setHeader()`.
|
|
457
|
+
*
|
|
458
|
+
* @param opts - Optional configuration (see {@link CorsOptions}). All fields
|
|
459
|
+
* are optional; unset fields fall back to permissive defaults
|
|
460
|
+
* (wildcard origin, no credentials, no max-age).
|
|
461
|
+
* @returns An Express-compatible middleware function.
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* ```ts
|
|
465
|
+
* // Allow exactly two known origins, denying everything else
|
|
466
|
+
* app.use(cors({ origin: ['https://app.example.com', 'https://admin.example.com'] }));
|
|
467
|
+
* ```
|
|
468
|
+
*/
|
|
228
469
|
export declare function cors(opts?: Partial<CorsOptions>): Middleware;
|
|
229
470
|
declare const _default: {
|
|
230
471
|
json: typeof json;
|
|
231
472
|
formData: typeof formData;
|
|
473
|
+
formEncoded: typeof formEncoded;
|
|
232
474
|
parseBody: typeof parseBody;
|
|
233
475
|
logger: typeof logger;
|
|
234
476
|
cors: typeof cors;
|
|
477
|
+
streamFormData: typeof streamFormData;
|
|
235
478
|
};
|
|
236
479
|
export default _default;
|
|
237
480
|
//# sourceMappingURL=misc.d.ts.map
|
package/dist/misc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../src/misc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../src/misc.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM7E;;;;GAIG;AACH,KAAK,OAAO,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;AAExD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,MAAM,EAAE,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