shelving 1.174.1 → 1.175.0
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/endpoint/Endpoint.d.ts +2 -2
- package/endpoint/util.d.ts +2 -2
- package/package.json +1 -1
- package/util/http.d.ts +5 -3
package/endpoint/Endpoint.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Schema } from "../schema/Schema.js";
|
|
2
2
|
import { type Data } from "../util/data.js";
|
|
3
3
|
import type { AnyCaller, Arguments } from "../util/function.js";
|
|
4
|
-
import { type
|
|
4
|
+
import { type OptionalRequestHandler, type RequestMethod, type RequestOptions } from "../util/http.js";
|
|
5
5
|
import { type URLString } from "../util/url.js";
|
|
6
6
|
import type { EndpointCallback } from "./util.js";
|
|
7
7
|
/**
|
|
@@ -27,7 +27,7 @@ export declare class Endpoint<P, R> {
|
|
|
27
27
|
*
|
|
28
28
|
* @param callback The callback function that implements the logic for this endpoint by receiving the payload and returning the response.
|
|
29
29
|
*/
|
|
30
|
-
handler<A extends Arguments = []>(callback: EndpointCallback<P, R, A>):
|
|
30
|
+
handler<A extends Arguments = []>(callback: EndpointCallback<P, R, A>): OptionalRequestHandler<A>;
|
|
31
31
|
/**
|
|
32
32
|
* Render the URL for this endpoint with the given payload.
|
|
33
33
|
* - URL might contain `{placeholder}` values that are replaced with values from the payload.
|
package/endpoint/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Arguments } from "../util/function.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { OptionalRequestHandlers } from "../util/http.js";
|
|
3
3
|
/**
|
|
4
4
|
* A function that handles a endpoint request, with a payload and returns a result.
|
|
5
5
|
*
|
|
@@ -23,4 +23,4 @@ export type EndpointCallback<P, R, A extends Arguments = []> = (payload: P, requ
|
|
|
23
23
|
* @returns The resulting `Response` from the first handler that matches the `Request`.
|
|
24
24
|
* @throws `NotFoundError` if no handler matches the `Request`.
|
|
25
25
|
*/
|
|
26
|
-
export declare function handleEndpoints<A extends Arguments = []>(endpoints:
|
|
26
|
+
export declare function handleEndpoints<A extends Arguments = []>(endpoints: OptionalRequestHandlers<A>, request: Request, ...args: A): Promise<Response> | Response;
|
package/package.json
CHANGED
package/util/http.d.ts
CHANGED
|
@@ -3,10 +3,12 @@ import { ResponseError } from "../error/ResponseError.js";
|
|
|
3
3
|
import { type Data } from "./data.js";
|
|
4
4
|
import type { AnyCaller, Arguments } from "./function.js";
|
|
5
5
|
import type { URLString } from "./url.js";
|
|
6
|
-
/** A handler function takes a `Request` and optional extra arguments
|
|
7
|
-
export type RequestHandler<A extends Arguments = []> = (request: Request, ...args: A) => Response | Promise<Response
|
|
6
|
+
/** A handler function takes a `Request` and optional extra arguments and returns a `Response` (possibly asynchronously). */
|
|
7
|
+
export type RequestHandler<A extends Arguments = []> = (request: Request, ...args: A) => Response | Promise<Response>;
|
|
8
|
+
/** An optional request handler that may return `undefined` to indicate no match. */
|
|
9
|
+
export type OptionalRequestHandler<A extends Arguments = []> = (request: Request, ...args: A) => Response | Promise<Response> | undefined;
|
|
8
10
|
/** A list of optional request handlers. */
|
|
9
|
-
export type
|
|
11
|
+
export type OptionalRequestHandlers<A extends Arguments = []> = Iterable<OptionalRequestHandler<A>>;
|
|
10
12
|
export declare function _getMessageJSON(message: Request | Response, MessageError: typeof RequestError | typeof ResponseError, caller: AnyCaller): Promise<unknown>;
|
|
11
13
|
export declare function _getMessageFormData(message: Request | Response, MessageError: typeof RequestError | typeof ResponseError, caller: AnyCaller): Promise<unknown>;
|
|
12
14
|
export declare function _getMessageContent(message: Request | Response, MessageError: typeof RequestError | typeof ResponseError, caller: AnyCaller): Promise<unknown>;
|