nitro-nightly 3.1.0-20251029-124449-782162a4 → 3.1.0-20251029-134825-8a3a1571
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/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -1
- package/dist/presets/azure/runtime/azure-swa.mjs +1 -1
- package/dist/presets/standard/runtime/server.d.mts +1 -1
- package/dist/presets/standard/runtime/server.mjs +1 -1
- package/dist/runtime/internal/app.mjs +9 -8
- package/dist/types/index.d.mts +4 -3
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { useNitroApp, useNitroHooks } from "nitro/runtime";
|
|
|
4
4
|
import { trapUnhandledNodeErrors } from "nitro/runtime/internal";
|
|
5
5
|
const nitroApp = useNitroApp();
|
|
6
6
|
const nitroHooks = useNitroHooks();
|
|
7
|
-
export const appFetch = nitroApp.
|
|
7
|
+
export const appFetch = nitroApp.request;
|
|
8
8
|
export const closePrerenderer = () => nitroHooks.callHook("close");
|
|
9
9
|
nitroHooks.hook("error", (error, context) => {
|
|
10
10
|
if (!error.unhandled && error.status >= 500 && context.event?.req?.headers instanceof Headers && context.event.req.headers.get("x-nitro-prerender")) {
|
|
@@ -11,7 +11,7 @@ export async function handle(context, req) {
|
|
|
11
11
|
} else {
|
|
12
12
|
url = "/api/" + (req.params.url || "");
|
|
13
13
|
}
|
|
14
|
-
const response = await nitroApp.
|
|
14
|
+
const response = await nitroApp.request(url, {
|
|
15
15
|
method: req.method || void 0,
|
|
16
16
|
// https://github.com/Azure/azure-functions-nodejs-worker/issues/294
|
|
17
17
|
// https://github.com/Azure/azure-functions-host/issues/293
|
|
@@ -76,27 +76,27 @@ function createNitroApp() {
|
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
-
let
|
|
79
|
+
let appHandler = (req) => {
|
|
80
80
|
req.context ||= {};
|
|
81
81
|
req.context.nitro = req.context.nitro || { errors: [] };
|
|
82
82
|
return h3App.fetch(req);
|
|
83
83
|
};
|
|
84
84
|
if (import.meta._asyncContext) {
|
|
85
|
-
const originalHandler =
|
|
86
|
-
|
|
85
|
+
const originalHandler = appHandler;
|
|
86
|
+
appHandler = (req) => {
|
|
87
87
|
const asyncCtx = { request: req };
|
|
88
88
|
return nitroAsyncContext.callAsync(asyncCtx, () => originalHandler(req));
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
|
-
const
|
|
91
|
+
const request = (input, init, context) => {
|
|
92
92
|
const req = toRequest(input, init);
|
|
93
93
|
req.context = { ...req.context, ...context };
|
|
94
|
-
return Promise.resolve(
|
|
94
|
+
return Promise.resolve(appHandler(req));
|
|
95
95
|
};
|
|
96
96
|
const nativeFetch = globalThis.fetch;
|
|
97
97
|
globalThis.fetch = (input, init) => {
|
|
98
98
|
if (typeof input === "string" && input.charCodeAt(0) === 47) {
|
|
99
|
-
return
|
|
99
|
+
return request(input, init);
|
|
100
100
|
}
|
|
101
101
|
if ("_request" in input) {
|
|
102
102
|
input = input._request;
|
|
@@ -104,8 +104,9 @@ function createNitroApp() {
|
|
|
104
104
|
return nativeFetch(input, init);
|
|
105
105
|
};
|
|
106
106
|
const app = {
|
|
107
|
-
fetch:
|
|
108
|
-
|
|
107
|
+
fetch: appHandler,
|
|
108
|
+
request,
|
|
109
|
+
h3: h3App,
|
|
109
110
|
hooks,
|
|
110
111
|
captureError
|
|
111
112
|
};
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HTTPMethod, HTTPEvent,
|
|
1
|
+
import { HTTPMethod, HTTPEvent, H3EventContext, H3Core, HTTPHandler, HTTPError, ProxyOptions, Middleware } from 'h3';
|
|
2
2
|
import { FetchRequest, FetchOptions, FetchResponse } from 'ofetch';
|
|
3
3
|
import { HookableCore, Hookable, NestedHooks } from 'hookable';
|
|
4
4
|
import { ServerRequestContext, ServerRequest } from 'srvx';
|
|
@@ -145,10 +145,11 @@ interface CachedEventHandlerOptions extends Omit<CacheOptions<ResponseCacheEntry
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
interface NitroApp {
|
|
148
|
-
|
|
148
|
+
fetch: (req: Request) => Response | Promise<Response>;
|
|
149
|
+
request: (req: string | URL | Request, init?: RequestInit, context?: ServerRequestContext | H3EventContext) => Promise<Response>;
|
|
150
|
+
h3?: H3Core;
|
|
149
151
|
hooks?: HookableCore<NitroRuntimeHooks>;
|
|
150
152
|
captureError: CaptureError;
|
|
151
|
-
fetch: (req: string | URL | Request, init?: RequestInit, context?: ServerRequestContext | H3EventContext) => Promise<Response>;
|
|
152
153
|
}
|
|
153
154
|
interface NitroAppPlugin {
|
|
154
155
|
(nitro: NitroApp & {
|
package/package.json
CHANGED