@whatwg-node/server 0.10.0-alpha-20241125135107-f57895e3cc8e9724899983c32c8b503cbd283558 → 0.10.0-alpha-20241125144652-80241d3c2ff561dca70cd7ac7e19ba1bfe7509db
Sign up to get free protection for your applications and to get access to all the features.
@@ -65,11 +65,17 @@ function createServerAdapter(serverAdapterBaseObject, options) {
|
|
65
65
|
}
|
66
66
|
if (options?.plugins != null) {
|
67
67
|
for (const plugin of options.plugins) {
|
68
|
-
if (plugin
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
if (plugin != null) {
|
69
|
+
if (plugin.onRequest) {
|
70
|
+
onRequestHooks.push(plugin.onRequest);
|
71
|
+
}
|
72
|
+
if (plugin.onResponse) {
|
73
|
+
onResponseHooks.push(plugin.onResponse);
|
74
|
+
}
|
75
|
+
const disposeFn = plugin[disposablestack_1.DisposableSymbols.asyncDispose] || plugin[disposablestack_1.DisposableSymbols.dispose];
|
76
|
+
if (disposeFn != null) {
|
77
|
+
disposableStack.defer(disposeFn);
|
78
|
+
}
|
73
79
|
}
|
74
80
|
}
|
75
81
|
}
|
@@ -61,11 +61,17 @@ function createServerAdapter(serverAdapterBaseObject, options) {
|
|
61
61
|
}
|
62
62
|
if (options?.plugins != null) {
|
63
63
|
for (const plugin of options.plugins) {
|
64
|
-
if (plugin
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
if (plugin != null) {
|
65
|
+
if (plugin.onRequest) {
|
66
|
+
onRequestHooks.push(plugin.onRequest);
|
67
|
+
}
|
68
|
+
if (plugin.onResponse) {
|
69
|
+
onResponseHooks.push(plugin.onResponse);
|
70
|
+
}
|
71
|
+
const disposeFn = plugin[DisposableSymbols.asyncDispose] || plugin[DisposableSymbols.dispose];
|
72
|
+
if (disposeFn != null) {
|
73
|
+
disposableStack.defer(disposeFn);
|
74
|
+
}
|
69
75
|
}
|
70
76
|
}
|
71
77
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@whatwg-node/server",
|
3
|
-
"version": "0.10.0-alpha-
|
3
|
+
"version": "0.10.0-alpha-20241125144652-80241d3c2ff561dca70cd7ac7e19ba1bfe7509db",
|
4
4
|
"description": "Fetch API compliant HTTP Server adapter",
|
5
5
|
"sideEffects": false,
|
6
6
|
"dependencies": {
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import { FetchAPI, ServerAdapterRequestHandler, type ServerAdapterInitialContext } from '../types.cjs';
|
2
|
-
export
|
2
|
+
export type ServerAdapterPlugin<TServerContext = {}> = {
|
3
3
|
onRequest?: OnRequestHook<TServerContext & ServerAdapterInitialContext>;
|
4
4
|
onResponse?: OnResponseHook<TServerContext & ServerAdapterInitialContext>;
|
5
|
-
|
5
|
+
[Symbol.dispose]?: () => void;
|
6
|
+
[Symbol.asyncDispose]?: () => PromiseLike<void> | void;
|
7
|
+
} | undefined;
|
6
8
|
export type OnRequestHook<TServerContext> = (payload: OnRequestEventPayload<TServerContext>) => Promise<void> | void;
|
7
9
|
export interface OnRequestEventPayload<TServerContext> {
|
8
10
|
request: Request;
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import { FetchAPI, ServerAdapterRequestHandler, type ServerAdapterInitialContext } from '../types.js';
|
2
|
-
export
|
2
|
+
export type ServerAdapterPlugin<TServerContext = {}> = {
|
3
3
|
onRequest?: OnRequestHook<TServerContext & ServerAdapterInitialContext>;
|
4
4
|
onResponse?: OnResponseHook<TServerContext & ServerAdapterInitialContext>;
|
5
|
-
|
5
|
+
[Symbol.dispose]?: () => void;
|
6
|
+
[Symbol.asyncDispose]?: () => PromiseLike<void> | void;
|
7
|
+
} | undefined;
|
6
8
|
export type OnRequestHook<TServerContext> = (payload: OnRequestEventPayload<TServerContext>) => Promise<void> | void;
|
7
9
|
export interface OnRequestEventPayload<TServerContext> {
|
8
10
|
request: Request;
|