nitro-nightly 3.1.0-20251026-232057-ce388de2 → 3.1.0-20251027-223403-81bd673d
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/_chunks/info.mjs +6 -6
- 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 +23 -26
- package/dist/runtime/internal/error/prod.d.mts +3 -2
- package/dist/runtime/internal/error/prod.mjs +9 -13
- package/dist/runtime/internal/routes/dev-tasks.d.mts +30 -2
- package/package.json +2 -2
package/dist/_chunks/info.mjs
CHANGED
|
@@ -10350,7 +10350,8 @@ function routing(nitro) {
|
|
|
10350
10350
|
"_importHash"
|
|
10351
10351
|
);
|
|
10352
10352
|
const h3Imports = [
|
|
10353
|
-
|
|
10353
|
+
allHandlers.some((h) => !h.lazy) && "toEventHandler",
|
|
10354
|
+
nitro.options.serverEntry && "toMiddleware",
|
|
10354
10355
|
allHandlers.some((h) => h.lazy) && "defineLazyEventHandler"
|
|
10355
10356
|
].filter(Boolean);
|
|
10356
10357
|
return (
|
|
@@ -10382,11 +10383,10 @@ export const hasRoutedMiddleware = ${nitro.routing.routedMiddleware.hasRoutes()
|
|
|
10382
10383
|
export const findRoutedMiddleware = ${nitro.routing.routedMiddleware.compileToString({ serialize: serializeHandler, matchAll: true })};
|
|
10383
10384
|
|
|
10384
10385
|
export const hasGlobalMiddleware = ${nitro.routing.globalMiddleware.length > 0 || nitro.options.serverEntry ? "true" : "false"};
|
|
10385
|
-
export const globalMiddleware = [
|
|
10386
|
-
|
|
10387
|
-
${nitro.options.serverEntry
|
|
10388
|
-
|
|
10389
|
-
if (serverEntry) { globalMiddleware.push(serverEntry) }`}
|
|
10386
|
+
export const globalMiddleware = [
|
|
10387
|
+
${nitro.routing.globalMiddleware.map((h) => h.lazy ? h._importHash : `toEventHandler(${h._importHash})`).join(",")}
|
|
10388
|
+
${nitro.options.serverEntry ? `,toMiddleware(__serverEntry__)` : ""}
|
|
10389
|
+
].filter(Boolean);
|
|
10390
10390
|
`
|
|
10391
10391
|
);
|
|
10392
10392
|
},
|
|
@@ -63,7 +63,7 @@ function createNitroApp() {
|
|
|
63
63
|
let fetchHandler = (req) => {
|
|
64
64
|
req.context ??= {};
|
|
65
65
|
req.context.nitro = req.context.nitro || { errors: [] };
|
|
66
|
-
return h3App.
|
|
66
|
+
return h3App.fetch(req);
|
|
67
67
|
};
|
|
68
68
|
if (import.meta._asyncContext) {
|
|
69
69
|
const originalFetchHandler = fetchHandler;
|
|
@@ -101,34 +101,31 @@ function createNitroApp() {
|
|
|
101
101
|
}
|
|
102
102
|
function createH3App(config) {
|
|
103
103
|
const h3App = new H3Core(config);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
104
|
+
hasRoutes && (h3App["~findRoute"] = (event) => findRoute(event.req.method, event.url.pathname));
|
|
105
|
+
hasGlobalMiddleware && h3App["~middleware"].push(...globalMiddleware);
|
|
106
|
+
if (hasRouteRules || hasRoutedMiddleware) {
|
|
107
|
+
h3App["~getMiddleware"] = (event, route) => {
|
|
108
|
+
const needsRouting = hasRouteRules || hasRoutedMiddleware;
|
|
109
|
+
const pathname = needsRouting ? event.url.pathname : void 0;
|
|
110
|
+
const method = needsRouting ? event.req.method : void 0;
|
|
111
|
+
const middleware = [];
|
|
112
|
+
if (hasRouteRules) {
|
|
113
|
+
const routeRules = getRouteRules(method, pathname);
|
|
114
|
+
event.context.routeRules = routeRules?.routeRules;
|
|
115
|
+
if (routeRules?.routeRuleMiddleware.length) {
|
|
116
|
+
middleware.push(...routeRules.routeRuleMiddleware);
|
|
117
|
+
}
|
|
117
118
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
middleware.push(...globalMiddleware);
|
|
121
|
-
}
|
|
122
|
-
if (hasRoutedMiddleware) {
|
|
123
|
-
middleware.push(
|
|
119
|
+
hasGlobalMiddleware && middleware.push(...h3App["~middleware"]);
|
|
120
|
+
hasRoutedMiddleware && middleware.push(
|
|
124
121
|
...findRoutedMiddleware(method, pathname).map((r) => r.data)
|
|
125
122
|
);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
123
|
+
if (hasRoutes && route?.data?.middleware?.length) {
|
|
124
|
+
middleware.push(...route.data.middleware);
|
|
125
|
+
}
|
|
126
|
+
return middleware;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
132
129
|
return h3App;
|
|
133
130
|
}
|
|
134
131
|
function getRouteRules(method, pathname) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { HTTPError, HTTPEvent } from "h3";
|
|
2
2
|
import type { InternalHandlerResponse } from "./utils.mjs";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import type { NitroErrorHandler } from "nitro/types";
|
|
4
|
+
declare const errorHandler: NitroErrorHandler;
|
|
5
|
+
export default errorHandler;
|
|
5
6
|
export declare function defaultHandler(error: HTTPError, event: HTTPEvent, opts?: {
|
|
6
7
|
silent?: boolean;
|
|
7
8
|
json?: boolean;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { getRequestURL } from "h3";
|
|
2
|
-
import { defineNitroErrorHandler } from "./utils.mjs";
|
|
3
1
|
import { FastResponse } from "srvx";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
);
|
|
2
|
+
const errorHandler = (error, event) => {
|
|
3
|
+
const res = defaultHandler(error, event);
|
|
4
|
+
return new FastResponse(
|
|
5
|
+
typeof res.body === "string" ? res.body : JSON.stringify(res.body, null, 2),
|
|
6
|
+
res
|
|
7
|
+
);
|
|
8
|
+
};
|
|
9
|
+
export default errorHandler;
|
|
10
10
|
export function defaultHandler(error, event, opts) {
|
|
11
11
|
const isSensitive = error.unhandled;
|
|
12
12
|
const status = error.status || 500;
|
|
13
|
-
const url =
|
|
13
|
+
const url = event.url || new URL(event.req.url);
|
|
14
14
|
if (status === 404) {
|
|
15
15
|
const baseURL = import.meta.baseURL || "/";
|
|
16
16
|
if (/^\/[^/]/.test(baseURL) && !url.pathname.startsWith(baseURL)) {
|
|
@@ -33,13 +33,9 @@ export function defaultHandler(error, event, opts) {
|
|
|
33
33
|
}
|
|
34
34
|
const headers = {
|
|
35
35
|
"content-type": "application/json",
|
|
36
|
-
// Prevent browser from guessing the MIME types of resources.
|
|
37
36
|
"x-content-type-options": "nosniff",
|
|
38
|
-
// Prevent error page from being embedded in an iframe
|
|
39
37
|
"x-frame-options": "DENY",
|
|
40
|
-
// Prevent browsers from sending the Referer header
|
|
41
38
|
"referrer-policy": "no-referrer",
|
|
42
|
-
// Disable the execution of any js
|
|
43
39
|
"content-security-policy": "script-src 'none'; frame-ancestors 'none';"
|
|
44
40
|
};
|
|
45
41
|
if (status === 404 || !event.res.headers.has("cache-control")) {
|
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const _default: {
|
|
2
|
+
"~rou3": import("h3").RouterContext;
|
|
3
|
+
request(request: import("srvx").ServerRequest | URL | string, options?: RequestInit, context?: import("h3").H3EventContext): Response | Promise<Response>;
|
|
4
|
+
use(route: string, handler: import("h3").Middleware, opts?: import("h3").MiddlewareOptions): /*elided*/ any;
|
|
5
|
+
use(handler: import("h3").Middleware, opts?: import("h3").MiddlewareOptions): /*elided*/ any;
|
|
6
|
+
on(method: import("h3").HTTPMethod | Lowercase<import("h3").HTTPMethod> | "", route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
7
|
+
register(plugin: import("h3").H3Plugin): /*elided*/ any;
|
|
8
|
+
mount(base: string, input: import("srvx").FetchHandler | {
|
|
9
|
+
fetch: import("srvx").FetchHandler;
|
|
10
|
+
} | /*elided*/ any): /*elided*/ any;
|
|
11
|
+
all(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
12
|
+
get(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
13
|
+
post(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
14
|
+
put(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
15
|
+
delete(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
16
|
+
patch(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
17
|
+
head(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
18
|
+
options(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
19
|
+
connect(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
20
|
+
trace(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
21
|
+
readonly config: import("h3").H3Config;
|
|
22
|
+
"~middleware": import("h3").Middleware[];
|
|
23
|
+
"~routes": import("h3").H3Route[];
|
|
24
|
+
fetch(_request: import("srvx").ServerRequest): Response | Promise<Response>;
|
|
25
|
+
handler(event: import("h3").H3Event): unknown | Promise<unknown>;
|
|
26
|
+
"~request"(request: import("srvx").ServerRequest, context?: import("h3").H3EventContext): Response | Promise<Response>;
|
|
27
|
+
"~findRoute"(_event: import("h3").H3Event): import("h3").MatchedRoute<import("h3").H3Route> | void;
|
|
28
|
+
"~getMiddleware"(event: import("h3").H3Event, route: import("h3").MatchedRoute<import("h3").H3Route> | undefined): import("h3").Middleware[];
|
|
29
|
+
"~addRoute"(_route: import("h3").H3Route): void;
|
|
30
|
+
};
|
|
3
31
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-nightly",
|
|
3
|
-
"version": "3.1.0-
|
|
3
|
+
"version": "3.1.0-20251027-223403-81bd673d",
|
|
4
4
|
"description": "Build and Deploy Universal JavaScript Servers",
|
|
5
5
|
"homepage": "https://nitro.build",
|
|
6
6
|
"repository": "nitrojs/nitro",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"db0": "^0.3.4",
|
|
59
59
|
"esbuild": "^0.25.11",
|
|
60
60
|
"fetchdts": "^0.1.7",
|
|
61
|
-
"h3": "^2.0.1-rc.
|
|
61
|
+
"h3": "^2.0.1-rc.5",
|
|
62
62
|
"jiti": "^2.6.1",
|
|
63
63
|
"nf3": "^0.1.2",
|
|
64
64
|
"ofetch": "^1.4.1",
|