@whatwg-node/server 0.7.0 → 0.7.1-rc-20230221123338-5fcbede
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/index.js +0 -8
- package/index.mjs +0 -8
- package/package.json +1 -1
- package/plugins/types.d.ts +0 -5
- package/types.d.ts +1 -4
package/index.js
CHANGED
|
@@ -269,14 +269,6 @@ function createServerAdapter(serverAdapterBaseObject, options) {
|
|
|
269
269
|
const onResponseHooks = [];
|
|
270
270
|
if ((options === null || options === void 0 ? void 0 : options.plugins) != null) {
|
|
271
271
|
for (const plugin of options.plugins) {
|
|
272
|
-
if (plugin.onPluginInit) {
|
|
273
|
-
plugin.onPluginInit({
|
|
274
|
-
addPlugin(newPlugin) {
|
|
275
|
-
options.plugins.push(newPlugin);
|
|
276
|
-
},
|
|
277
|
-
});
|
|
278
|
-
delete plugin.onPluginInit;
|
|
279
|
-
}
|
|
280
272
|
if (plugin.onRequest) {
|
|
281
273
|
onRequestHooks.push(plugin.onRequest);
|
|
282
274
|
}
|
package/index.mjs
CHANGED
|
@@ -267,14 +267,6 @@ function createServerAdapter(serverAdapterBaseObject, options) {
|
|
|
267
267
|
const onResponseHooks = [];
|
|
268
268
|
if ((options === null || options === void 0 ? void 0 : options.plugins) != null) {
|
|
269
269
|
for (const plugin of options.plugins) {
|
|
270
|
-
if (plugin.onPluginInit) {
|
|
271
|
-
plugin.onPluginInit({
|
|
272
|
-
addPlugin(newPlugin) {
|
|
273
|
-
options.plugins.push(newPlugin);
|
|
274
|
-
},
|
|
275
|
-
});
|
|
276
|
-
delete plugin.onPluginInit;
|
|
277
|
-
}
|
|
278
270
|
if (plugin.onRequest) {
|
|
279
271
|
onRequestHooks.push(plugin.onRequest);
|
|
280
272
|
}
|
package/package.json
CHANGED
package/plugins/types.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { FetchAPI, ServerAdapterRequestHandler } from '../types';
|
|
2
2
|
export interface ServerAdapterPlugin<TServerContext = {}> {
|
|
3
|
-
onPluginInit?: OnPluginInitHook;
|
|
4
3
|
onRequest?: OnRequestHook<TServerContext>;
|
|
5
4
|
onResponse?: OnResponseHook<TServerContext>;
|
|
6
5
|
}
|
|
7
|
-
export type OnPluginInitHook = (payload: OnPluginInitEventPayload) => void;
|
|
8
|
-
export interface OnPluginInitEventPayload {
|
|
9
|
-
addPlugin(plugin: ServerAdapterPlugin<any>): void;
|
|
10
|
-
}
|
|
11
6
|
export type OnRequestHook<TServerContext> = (payload: OnRequestEventPayload<TServerContext>) => Promise<void> | void;
|
|
12
7
|
export interface OnRequestEventPayload<TServerContext> {
|
|
13
8
|
request: Request;
|
package/types.d.ts
CHANGED
|
@@ -47,13 +47,10 @@ export interface ServerAdapterObject<TServerContext> extends EventListenerObject
|
|
|
47
47
|
} & Partial<TServerContext>, ...ctx: Partial<TServerContext>[]): Promise<Response> | Response;
|
|
48
48
|
}
|
|
49
49
|
export type ServerAdapter<TServerContext, TBaseObject extends ServerAdapterBaseObject<TServerContext>> = TBaseObject & ServerAdapterObject<TServerContext>['handle'] & ServerAdapterObject<TServerContext>;
|
|
50
|
-
export type ServerAdapterRequestHandler<TServerContext> = (request: Request, ctx:
|
|
50
|
+
export type ServerAdapterRequestHandler<TServerContext> = (request: Request, ctx: TServerContext) => Promise<Response> | Response;
|
|
51
51
|
export type ServerAdapterNodeContext = {
|
|
52
52
|
req: NodeRequest;
|
|
53
53
|
res: NodeResponse;
|
|
54
54
|
};
|
|
55
55
|
export type WaitUntilFn = (promise: Promise<void> | void) => void;
|
|
56
|
-
export type ServerAdapterContext<TServerContext> = TServerContext & {
|
|
57
|
-
waitUntil: WaitUntilFn;
|
|
58
|
-
};
|
|
59
56
|
export type FetchAPI = ReturnType<typeof import('@whatwg-node/fetch').createFetch>;
|