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.
@@ -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.fetch;
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.fetch(url, {
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
@@ -1,5 +1,5 @@
1
1
  import "#nitro-internal-pollyfills";
2
2
  declare const _default: {
3
- fetch: (req: Request) => any;
3
+ fetch: any;
4
4
  };
5
5
  export default _default;
@@ -2,5 +2,5 @@ import "#nitro-internal-pollyfills";
2
2
  import { useNitroApp } from "nitro/runtime";
3
3
  const nitroApp = useNitroApp();
4
4
  export default {
5
- fetch: (req) => nitroApp.fetch(req)
5
+ fetch: nitroApp.fetch
6
6
  };
@@ -76,27 +76,27 @@ function createNitroApp() {
76
76
  });
77
77
  };
78
78
  }
79
- let appReqHandler = (req) => {
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 = appReqHandler;
86
- appReqHandler = (req) => {
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 appFetchHandler = (input, init, context) => {
91
+ const request = (input, init, context) => {
92
92
  const req = toRequest(input, init);
93
93
  req.context = { ...req.context, ...context };
94
- return Promise.resolve(appReqHandler(req));
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 appFetchHandler(input, init);
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: appFetchHandler,
108
- _h3: h3App,
107
+ fetch: appHandler,
108
+ request,
109
+ h3: h3App,
109
110
  hooks,
110
111
  captureError
111
112
  };
@@ -1,4 +1,4 @@
1
- import { HTTPMethod, HTTPEvent, H3Core, H3EventContext, HTTPHandler, HTTPError, ProxyOptions, Middleware } from 'h3';
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
- _h3?: H3Core;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-nightly",
3
- "version": "3.1.0-20251029-124449-782162a4",
3
+ "version": "3.1.0-20251029-134825-8a3a1571",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "homepage": "https://nitro.build",
6
6
  "repository": "nitrojs/nitro",