nitro 3.0.1-alpha.2 → 3.0.260415-beta
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/LICENSE +6 -0
- package/README.md +2 -2
- package/dist/THIRD-PARTY-LICENSES.md +1646 -0
- package/dist/_build/common.mjs +7261 -3812
- package/dist/_build/rolldown.mjs +32 -42
- package/dist/_build/rollup.mjs +28 -48
- package/dist/_build/vite.build.mjs +10 -10
- package/dist/_chunks/nitro.mjs +102 -327
- package/dist/_chunks/nitro2.mjs +8 -9
- package/dist/_chunks/nitro3.mjs +136 -0
- package/dist/_chunks/nitro4.mjs +127 -0
- package/dist/_chunks/utils.mjs +40 -29
- package/dist/_common.mjs +13 -25
- package/dist/_dev.d.mts +0 -3
- package/dist/{_chunks/dev.mjs → _dev.mjs} +132 -330
- package/dist/_libs/_.mjs +2 -0
- package/dist/_libs/_2.mjs +2 -0
- package/dist/_libs/_3.mjs +2 -0
- package/dist/_libs/_4.mjs +2 -0
- package/dist/_libs/_5.mjs +2 -0
- package/dist/_libs/_6.mjs +2 -0
- package/dist/_libs/_7.mjs +2 -0
- package/dist/_libs/c12+rc9.mjs +814 -0
- package/dist/_libs/{c12+giget+readdirp+chokidar.d.mts → c12+readdirp+chokidar.d.mts} +49 -40
- package/dist/_libs/citty.mjs +142 -41
- package/dist/_libs/commondir+is-reference.mjs +60 -56
- package/dist/_libs/compatx.d.mts +0 -2
- package/dist/_libs/compatx.mjs +1 -4
- package/dist/_libs/esbuild.d.mts +0 -1
- package/dist/_libs/escape-string-regexp.mjs +1 -4
- package/dist/_libs/{pluginutils+plugin-commonjs.d.mts → estree+pluginutils.d.mts} +0 -5
- package/dist/_libs/estree-walker.mjs +4 -92
- package/dist/_libs/exsolve.d.mts +1 -0
- package/dist/_libs/hasown+resolve+deepmerge.mjs +160 -246
- package/dist/_libs/httpxy.d.mts +20 -13
- package/dist/_libs/httpxy.mjs +519 -95
- package/dist/_libs/js-tokens.d.mts +1 -0
- package/dist/_libs/klona.mjs +1 -4
- package/dist/_libs/magic-string.d.mts +0 -2
- package/dist/_libs/mlly.d.mts +0 -2
- package/dist/_libs/nypm+tinyexec.mjs +822 -0
- package/dist/_libs/perfect-debounce.mjs +68 -0
- package/dist/_libs/pkg-types.d.mts +0 -3
- package/dist/_libs/plugin-alias.mjs +1 -5
- package/dist/_libs/plugin-inject.mjs +1 -7
- package/dist/_libs/plugin-json.mjs +1 -5
- package/dist/_libs/pluginutils.mjs +3 -35
- package/dist/_libs/readdirp+chokidar.mjs +187 -365
- package/dist/_libs/remapping.mjs +1 -5
- package/dist/_libs/resolve-uri+gen-mapping.mjs +15 -53
- package/dist/_libs/rou3.d.mts +1 -4
- package/dist/_libs/rou3.mjs +223 -78
- package/dist/_libs/std-env.d.mts +8 -2
- package/dist/_libs/strip-literal.d.mts +1 -0
- package/dist/_libs/tsconfck.mjs +21 -334
- package/dist/_libs/ultrahtml.mjs +3 -16
- package/dist/_libs/unimport+unplugin.mjs +244 -388
- package/dist/_libs/unplugin+unimport.d.mts +5 -15
- package/dist/_libs/unwasm.d.mts +0 -3
- package/dist/_presets.mjs +576 -488
- package/dist/builder.d.mts +5 -25
- package/dist/builder.mjs +3 -8
- package/dist/cli/_chunks/build.mjs +22 -25
- package/dist/cli/_chunks/common.mjs +1 -4
- package/dist/cli/_chunks/deploy.mjs +37 -0
- package/dist/cli/_chunks/dev.mjs +6 -11
- package/dist/cli/_chunks/docs.mjs +28 -0
- package/dist/cli/_chunks/list.mjs +4 -8
- package/dist/cli/_chunks/prepare.mjs +2 -6
- package/dist/cli/_chunks/preview.mjs +48 -0
- package/dist/cli/_chunks/run.mjs +7 -11
- package/dist/cli/_chunks/task.mjs +1 -5
- package/dist/cli/index.mjs +5 -6
- package/dist/docs/0.docs/0.index/index.md +56 -0
- package/dist/docs/0.docs/1.quick-start.md +110 -0
- package/dist/docs/0.docs/10.lifecycle.md +204 -0
- package/dist/docs/0.docs/11.openapi.md +291 -0
- package/dist/docs/0.docs/12.plugins.md +164 -0
- package/dist/docs/0.docs/13.tasks.md +277 -0
- package/dist/docs/0.docs/14.websocket.md +386 -0
- package/dist/docs/0.docs/15.migration.md +213 -0
- package/dist/docs/0.docs/16.nightly.md +31 -0
- package/dist/docs/0.docs/2.renderer.md +322 -0
- package/dist/docs/0.docs/3.routing.md +711 -0
- package/dist/docs/0.docs/4.server-entry.md +239 -0
- package/dist/docs/0.docs/5.cache.md +408 -0
- package/dist/docs/0.docs/6.storage.md +261 -0
- package/dist/docs/0.docs/7.assets.md +166 -0
- package/dist/docs/0.docs/8.configuration.md +256 -0
- package/dist/docs/0.docs/9.database.md +185 -0
- package/dist/docs/1.deploy/0.index/index.md +64 -0
- package/dist/docs/1.deploy/1.runtimes/0.node.md +63 -0
- package/dist/docs/1.deploy/1.runtimes/1.bun.md +15 -0
- package/dist/docs/1.deploy/1.runtimes/2.deno.md +19 -0
- package/dist/docs/1.deploy/2.providers/0.alwaysdata.md +50 -0
- package/dist/docs/1.deploy/2.providers/1.aws.md +47 -0
- package/dist/docs/1.deploy/2.providers/10.flightcontrol.md +67 -0
- package/dist/docs/1.deploy/2.providers/11.genezio.md +67 -0
- package/dist/docs/1.deploy/2.providers/12.github-pages.md +68 -0
- package/dist/docs/1.deploy/2.providers/13.gitlab-pages.md +37 -0
- package/dist/docs/1.deploy/2.providers/14.heroku.md +84 -0
- package/dist/docs/1.deploy/2.providers/15.iis.md +38 -0
- package/dist/docs/1.deploy/2.providers/16.koyeb.md +109 -0
- package/dist/docs/1.deploy/2.providers/17.netlify.md +47 -0
- package/dist/docs/1.deploy/2.providers/18.platform-sh.md +37 -0
- package/dist/docs/1.deploy/2.providers/19.render.md +37 -0
- package/dist/docs/1.deploy/2.providers/2.aws-amplify.md +81 -0
- package/dist/docs/1.deploy/2.providers/20.stormkit.md +24 -0
- package/dist/docs/1.deploy/2.providers/21.vercel.md +270 -0
- package/dist/docs/1.deploy/2.providers/22.zeabur.md +19 -0
- package/dist/docs/1.deploy/2.providers/23.zephyr.md +99 -0
- package/dist/docs/1.deploy/2.providers/24.zerops.md +102 -0
- package/dist/docs/1.deploy/2.providers/3.azure.md +72 -0
- package/dist/docs/1.deploy/2.providers/4.cleavr.md +33 -0
- package/dist/docs/1.deploy/2.providers/5.cloudflare.md +369 -0
- package/dist/docs/1.deploy/2.providers/6.deno-deploy.md +66 -0
- package/dist/docs/1.deploy/2.providers/7.digitalocean.md +46 -0
- package/dist/docs/1.deploy/2.providers/8.edgeone.md +20 -0
- package/dist/docs/1.deploy/2.providers/9.firebase.md +32 -0
- package/dist/docs/2.config/0.index/index.md +1221 -0
- package/dist/docs/3.examples/0.index/index.md +3 -0
- package/dist/docs/3.examples/1.api-routes.md +145 -0
- package/dist/docs/3.examples/10.hono.md +74 -0
- package/dist/docs/3.examples/11.import-alias.md +97 -0
- package/dist/docs/3.examples/12.middleware.md +91 -0
- package/dist/docs/3.examples/13.mono-jsx.md +68 -0
- package/dist/docs/3.examples/14.nano-jsx.md +70 -0
- package/dist/docs/3.examples/15.plugins.md +91 -0
- package/dist/docs/3.examples/16.renderer.md +113 -0
- package/dist/docs/3.examples/17.runtime-config.md +97 -0
- package/dist/docs/3.examples/18.server-fetch.md +87 -0
- package/dist/docs/3.examples/19.shiki.md +198 -0
- package/dist/docs/3.examples/2.auto-imports.md +92 -0
- package/dist/docs/3.examples/20.virtual-routes.md +74 -0
- package/dist/docs/3.examples/21.vite-nitro-plugin.md +79 -0
- package/dist/docs/3.examples/22.vite-rsc.md +1041 -0
- package/dist/docs/3.examples/23.vite-ssr-html.md +217 -0
- package/dist/docs/3.examples/24.vite-ssr-preact.md +247 -0
- package/dist/docs/3.examples/25.vite-ssr-react.md +226 -0
- package/dist/docs/3.examples/26.vite-ssr-solid.md +256 -0
- package/dist/docs/3.examples/27.vite-ssr-tsr-react.md +442 -0
- package/dist/docs/3.examples/28.vite-ssr-tss-react.md +444 -0
- package/dist/docs/3.examples/29.vite-ssr-vue-router.md +617 -0
- package/dist/docs/3.examples/3.cached-handler.md +81 -0
- package/dist/docs/3.examples/30.vite-trpc.md +335 -0
- package/dist/docs/3.examples/31.websocket.md +282 -0
- package/dist/docs/3.examples/4.custom-error-handler.md +98 -0
- package/dist/docs/3.examples/5.database.md +157 -0
- package/dist/docs/3.examples/6.elysia.md +70 -0
- package/dist/docs/3.examples/7.express.md +78 -0
- package/dist/docs/3.examples/8.fastify.md +79 -0
- package/dist/docs/3.examples/9.hello-world.md +68 -0
- package/dist/docs/README.md +86 -0
- package/dist/docs/index.md +121 -0
- package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +8 -0
- package/dist/node_modules/@poppinss/dumper/package.json +1 -1
- package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -4
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -2
- package/dist/node_modules/@speed-highlight/core/package.json +1 -1
- package/dist/node_modules/cookie-es/dist/index.mjs +299 -250
- package/dist/node_modules/cookie-es/package.json +26 -23
- package/dist/node_modules/croner/dist/croner.js +1 -1
- package/dist/node_modules/croner/package.json +11 -1
- package/dist/node_modules/defu/dist/defu.mjs +2 -2
- package/dist/node_modules/defu/package.json +33 -28
- package/dist/node_modules/rendu/dist/_chunks/libs/cookie-es.mjs +151 -0
- package/dist/node_modules/rendu/dist/index.mjs +5 -112
- package/dist/node_modules/rendu/package.json +25 -24
- package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
- package/dist/node_modules/youch/build/index.js +204 -351
- package/dist/node_modules/youch/build/public/error_info/script.js +1 -1
- package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
- package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
- package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
- package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
- package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
- package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
- package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
- package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
- package/dist/node_modules/youch/package.json +35 -32
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +12 -57
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +1 -2
- package/dist/presets/aws-lambda/runtime/_utils.mjs +6 -6
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +3 -1
- package/dist/presets/azure/runtime/_utils.mjs +5 -5
- package/dist/presets/azure/runtime/azure-swa.mjs +5 -5
- package/dist/presets/bun/runtime/bun.mjs +9 -6
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +4 -4
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +3 -3
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +2 -2
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +10 -21
- package/dist/presets/deno/runtime/deno-deploy.mjs +4 -4
- package/dist/presets/deno/runtime/deno-server.mjs +9 -6
- package/dist/presets/edgeone/runtime/edgeone.mjs +10 -0
- package/dist/presets/netlify/runtime/netlify-edge.mjs +2 -3
- package/dist/presets/netlify/runtime/netlify.mjs +1 -1
- package/dist/presets/node/runtime/node-cluster.mjs +5 -4
- package/dist/presets/node/runtime/node-middleware.mjs +1 -1
- package/dist/presets/node/runtime/node-server.mjs +8 -5
- package/dist/presets/stormkit/runtime/stormkit.mjs +1 -2
- package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
- package/dist/presets/vercel/runtime/queue-handler.mjs +21 -0
- package/dist/presets/vercel/runtime/vercel.node.mjs +3 -3
- package/dist/presets/vercel/runtime/vercel.web.mjs +3 -5
- package/dist/presets/winterjs/runtime/winterjs.mjs +10 -10
- package/dist/presets/zephyr/runtime/server.mjs +3 -0
- package/dist/runtime/internal/app.mjs +12 -11
- package/dist/runtime/internal/cache.d.mts +0 -4
- package/dist/runtime/internal/cache.mjs +32 -256
- package/dist/runtime/internal/context.d.mts +3 -1
- package/dist/runtime/internal/context.mjs +1 -9
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +47 -49
- package/dist/runtime/internal/error/hooks.d.mts +1 -1
- package/dist/runtime/internal/error/prod.d.mts +2 -5
- package/dist/runtime/internal/error/prod.mjs +19 -33
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/route-rules.d.mts +11 -4
- package/dist/runtime/internal/route-rules.mjs +15 -5
- package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -2
- package/dist/runtime/internal/routes/dev-tasks.mjs +15 -10
- package/dist/runtime/internal/routes/openapi.mjs +2 -2
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +2 -1
- package/dist/runtime/internal/routes/scalar.mjs +3 -3
- package/dist/runtime/internal/routes/swagger.mjs +7 -4
- package/dist/runtime/internal/runtime-config.d.mts +1 -1
- package/dist/runtime/internal/runtime-config.mjs +2 -2
- package/dist/runtime/internal/static.mjs +5 -4
- package/dist/runtime/internal/task.d.mts +3 -1
- package/dist/runtime/internal/task.mjs +7 -7
- package/dist/runtime/internal/vite/dev-entry.mjs +6 -3
- package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
- package/dist/runtime/meta.d.mts +1 -0
- package/dist/runtime/meta.mjs +2 -0
- package/dist/runtime/nitro.d.mts +2 -0
- package/dist/runtime/nitro.mjs +4 -2
- package/dist/runtime/virtual/error-handler.mjs +1 -1
- package/dist/runtime/virtual/renderer-template.mjs +1 -1
- package/dist/runtime/virtual/server-assets.d.mts +2 -1
- package/dist/runtime/virtual/tracing.d.mts +5 -0
- package/dist/runtime/virtual/tracing.mjs +1 -0
- package/dist/runtime/vite.d.mts +1 -1
- package/dist/types/index.d.mts +215 -195
- package/dist/types/index.mjs +1 -11
- package/dist/vite.d.mts +3 -8
- package/dist/vite.mjs +285 -253
- package/lib/tsconfig.json +3 -5
- package/package.json +97 -80
- package/dist/_libs/confbox.mjs +0 -2509
- package/dist/_libs/nypm+giget+tinyexec.mjs +0 -3603
- package/dist/_libs/rc9+c12+dotenv.mjs +0 -972
- package/dist/node_modules/hookable/dist/index.mjs +0 -266
- package/dist/node_modules/hookable/package.json +0 -52
- package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +0 -42
- package/dist/node_modules/youch/build/chunk-7QV3D5YX.js +0 -83
- package/dist/node_modules/youch/build/chunk-AUGPHE32.js +0 -39
- package/dist/node_modules/youch/build/chunk-CM7DWJNZ.js +0 -44
- package/dist/node_modules/youch/build/chunk-EJH674NB.js +0 -223
- package/dist/node_modules/youch/build/chunk-OIJ3WD7L.js +0 -81
- package/dist/node_modules/youch/build/chunk-P36L72PL.js +0 -87
- package/dist/node_modules/youch/build/chunk-PE3GG3TN.js +0 -65
- package/dist/node_modules/youch/build/chunk-X53OIOJH.js +0 -70
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +0 -2
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +0 -3
- package/dist/presets/_nitro/runtime/service-worker.d.mts +0 -2
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -8
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +0 -3
- package/dist/presets/azure/runtime/_utils.d.mts +0 -2
- package/dist/presets/azure/runtime/azure-swa.d.mts +0 -5
- package/dist/presets/bun/runtime/bun.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +0 -16
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +0 -11
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +0 -20
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +0 -3
- package/dist/presets/deno/runtime/deno-deploy.d.mts +0 -5
- package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify.d.mts +0 -4
- package/dist/presets/node/runtime/node-cluster.d.mts +0 -3
- package/dist/presets/node/runtime/node-middleware.d.mts +0 -3
- package/dist/presets/node/runtime/node-server.d.mts +0 -3
- package/dist/presets/standard/runtime/server.d.mts +0 -3
- package/dist/presets/stormkit/runtime/stormkit.d.mts +0 -21
- package/dist/presets/vercel/runtime/isr.d.mts +0 -2
- package/dist/presets/vercel/runtime/vercel.node.d.mts +0 -3
- package/dist/presets/vercel/runtime/vercel.web.d.mts +0 -8
- package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -2
- package/dist/presets/zeabur/runtime/zeabur.d.mts +0 -3
- package/dist/runtime/internal/vite/node-runner.mjs +0 -359
|
@@ -14,12 +14,12 @@ export function getAzureParsedCookiesFromHeaders(headers) {
|
|
|
14
14
|
const setCookieOptions = Object.fromEntries(_setCookieOptions.map(([k, v]) => [k.toLowerCase(), v]));
|
|
15
15
|
const cookieObject = {
|
|
16
16
|
name: key,
|
|
17
|
-
value,
|
|
17
|
+
value: value || "",
|
|
18
18
|
domain: setCookieOptions.domain,
|
|
19
19
|
path: setCookieOptions.path,
|
|
20
|
-
expires: parseNumberOrDate(setCookieOptions.expires),
|
|
20
|
+
expires: parseNumberOrDate(setCookieOptions.expires || ""),
|
|
21
21
|
sameSite: setCookieOptions.samesite,
|
|
22
|
-
maxAge: parseNumber(setCookieOptions["max-age"]),
|
|
22
|
+
maxAge: parseNumber(setCookieOptions["max-age"] || ""),
|
|
23
23
|
secure: setCookieStr.includes("Secure") ? true : undefined,
|
|
24
24
|
httpOnly: setCookieStr.includes("HttpOnly") ? true : undefined
|
|
25
25
|
};
|
|
@@ -32,7 +32,7 @@ function parseNumberOrDate(expires) {
|
|
|
32
32
|
if (expiresAsNumber !== undefined) {
|
|
33
33
|
return expiresAsNumber;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
const expiresAsDate = new Date(expires);
|
|
37
37
|
if (!Number.isNaN(expiresAsDate.getTime())) {
|
|
38
38
|
return expiresAsDate;
|
|
@@ -42,7 +42,7 @@ function parseNumber(maxAge) {
|
|
|
42
42
|
if (!maxAge) {
|
|
43
43
|
return undefined;
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
const maxAgeAsNumber = Number(maxAge);
|
|
47
47
|
if (!Number.isNaN(maxAgeAsNumber)) {
|
|
48
48
|
return maxAgeAsNumber;
|
|
@@ -6,12 +6,12 @@ const nitroApp = useNitroApp();
|
|
|
6
6
|
export async function handle(context, req) {
|
|
7
7
|
let url;
|
|
8
8
|
if (req.headers["x-ms-original-url"]) {
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
const parsedURL = parseURL(req.headers["x-ms-original-url"]);
|
|
11
11
|
url = parsedURL.pathname + parsedURL.search;
|
|
12
12
|
} else {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
|
|
14
|
+
|
|
15
15
|
url = "/api/" + (req.params.url || "");
|
|
16
16
|
}
|
|
17
17
|
const request = new Request(url, {
|
|
@@ -19,8 +19,8 @@ export async function handle(context, req) {
|
|
|
19
19
|
body: req.bufferBody ?? req.rawBody
|
|
20
20
|
});
|
|
21
21
|
const response = await nitroApp.fetch(request);
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
|
|
23
|
+
|
|
24
24
|
context.res = {
|
|
25
25
|
status: response.status,
|
|
26
26
|
body: response.body,
|
|
@@ -5,11 +5,13 @@ import { useNitroApp } from "nitro/app";
|
|
|
5
5
|
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
6
6
|
import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
|
|
7
7
|
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
8
|
-
|
|
8
|
+
import { tracingSrvxPlugins } from "#nitro/virtual/tracing";
|
|
9
|
+
const _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
|
|
10
|
+
const port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
|
|
9
11
|
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
10
12
|
const cert = process.env.NITRO_SSL_CERT;
|
|
11
13
|
const key = process.env.NITRO_SSL_KEY;
|
|
12
|
-
|
|
14
|
+
|
|
13
15
|
const nitroApp = useNitroApp();
|
|
14
16
|
let _fetch = nitroApp.fetch;
|
|
15
17
|
const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
|
|
@@ -21,7 +23,7 @@ if (import.meta._websocket) {
|
|
|
21
23
|
return nitroApp.fetch(req);
|
|
22
24
|
};
|
|
23
25
|
}
|
|
24
|
-
serve({
|
|
26
|
+
const server = serve({
|
|
25
27
|
port,
|
|
26
28
|
hostname: host,
|
|
27
29
|
tls: cert && key ? {
|
|
@@ -29,11 +31,12 @@ serve({
|
|
|
29
31
|
key
|
|
30
32
|
} : undefined,
|
|
31
33
|
fetch: _fetch,
|
|
32
|
-
bun: { websocket: import.meta._websocket ? ws?.websocket : undefined }
|
|
34
|
+
bun: { websocket: import.meta._websocket ? ws?.websocket : undefined },
|
|
35
|
+
plugins: [...tracingSrvxPlugins]
|
|
33
36
|
});
|
|
34
37
|
trapUnhandledErrors();
|
|
35
|
-
|
|
38
|
+
|
|
36
39
|
if (import.meta._tasks) {
|
|
37
|
-
startScheduleRunner();
|
|
40
|
+
startScheduleRunner({ waitUntil: server.waitUntil });
|
|
38
41
|
}
|
|
39
42
|
export default {};
|
|
@@ -23,14 +23,14 @@ const ws = import.meta._websocket ? wsAdapter({
|
|
|
23
23
|
bindingName: DURABLE_BINDING
|
|
24
24
|
}) : undefined;
|
|
25
25
|
export default createHandler({ fetch(request, env, context, url, ctxExt) {
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
if (env.ASSETS && isPublicAssetURL(url.pathname)) {
|
|
28
28
|
return env.ASSETS.fetch(request);
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
ctxExt.durableFetch = (req = request) => getDurableStub(env).fetch(req);
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
|
|
33
|
+
|
|
34
34
|
if (import.meta._websocket && request.headers.get("upgrade") === "websocket") {
|
|
35
35
|
return ws.handleUpgrade(request, env, context);
|
|
36
36
|
}
|
|
@@ -5,12 +5,12 @@ import { createHandler } from "./_module-handler.mjs";
|
|
|
5
5
|
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
6
6
|
const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
|
|
7
7
|
export default createHandler({ fetch(cfRequest, env, context, url) {
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
if (env.ASSETS && isPublicAssetURL(url.pathname)) {
|
|
10
10
|
return env.ASSETS.fetch(cfRequest);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
|
|
13
|
+
|
|
14
14
|
if (import.meta._websocket && cfRequest.headers.get("upgrade") === "websocket") {
|
|
15
15
|
return ws.handleUpgrade(cfRequest, env, context);
|
|
16
16
|
}
|
|
@@ -13,8 +13,8 @@ export default {
|
|
|
13
13
|
env,
|
|
14
14
|
context
|
|
15
15
|
});
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
|
|
17
|
+
|
|
18
18
|
if (import.meta._websocket && cfReq.headers.get("upgrade") === "websocket") {
|
|
19
19
|
return ws.handleUpgrade(cfReq, env, context);
|
|
20
20
|
}
|
|
@@ -7,32 +7,21 @@ globalThis.__env__ = proxy.env;
|
|
|
7
7
|
globalThis.__wait_until__ = proxy.ctx.waitUntil.bind(proxy.ctx);
|
|
8
8
|
const cloudflareDevPlugin = function(nitroApp) {
|
|
9
9
|
nitroApp.hooks.hook("request", async (event) => {
|
|
10
|
-
event.req.context ??= {};
|
|
11
|
-
// Inject the various cf values from the proxy in event and event.context
|
|
12
|
-
event.req.context.cf = proxy.cf;
|
|
13
|
-
event.req.context.waitUntil = proxy.ctx.waitUntil.bind(proxy.ctx);
|
|
14
10
|
const request = event.req;
|
|
15
|
-
request.
|
|
16
|
-
|
|
17
|
-
...
|
|
18
|
-
request,
|
|
11
|
+
request.runtime ??= { name: "cloudflare" };
|
|
12
|
+
request.runtime.cloudflare = {
|
|
13
|
+
...request.runtime.cloudflare,
|
|
19
14
|
env: proxy.env,
|
|
20
15
|
context: proxy.ctx
|
|
21
16
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// https://github.com/unjs/nitro/blob/main/src/runtime/app.ts#L120
|
|
25
|
-
// TODO: Update for v3
|
|
26
|
-
// (event.node.req as any).__unenv__ = {
|
|
27
|
-
// ...(event.node.req as any).__unenv__,
|
|
28
|
-
// waitUntil: event.context.waitUntil,
|
|
29
|
-
// };
|
|
17
|
+
request.waitUntil = proxy.ctx.waitUntil.bind(proxy.ctx);
|
|
18
|
+
request.cf = proxy.cf;
|
|
30
19
|
});
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
|
|
21
|
+
|
|
33
22
|
// @ts-expect-error
|
|
34
23
|
nitroApp.hooks._hooks.request.unshift(nitroApp.hooks._hooks.request.pop());
|
|
35
|
-
|
|
24
|
+
|
|
36
25
|
nitroApp.hooks.hook("close", () => {
|
|
37
26
|
return proxy?.dispose();
|
|
38
27
|
});
|
|
@@ -51,8 +40,8 @@ async function _getPlatformProxy() {
|
|
|
51
40
|
configPath: runtimeConfig.wrangler.configPath,
|
|
52
41
|
persist: { path: runtimeConfig.wrangler.persistDir }
|
|
53
42
|
};
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
|
|
44
|
+
|
|
56
45
|
if (runtimeConfig.wrangler.environment) {
|
|
57
46
|
proxyOptions.environment = runtimeConfig.wrangler.environment;
|
|
58
47
|
}
|
|
@@ -4,14 +4,14 @@ import { useNitroApp } from "nitro/app";
|
|
|
4
4
|
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
5
5
|
const nitroApp = useNitroApp();
|
|
6
6
|
const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
Deno.serve((denoReq, info) => {
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
const req = denoReq;
|
|
11
11
|
req.runtime ??= { name: "deno" };
|
|
12
12
|
req.runtime.deno ??= { info };
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
req.ip = info.remoteAddr.hostname;
|
|
14
|
+
|
|
15
15
|
if (import.meta._websocket && req.headers.get("upgrade") === "websocket") {
|
|
16
16
|
return ws.handleUpgrade(req, info);
|
|
17
17
|
}
|
|
@@ -5,11 +5,13 @@ import { useNitroApp } from "nitro/app";
|
|
|
5
5
|
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
6
6
|
import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
|
|
7
7
|
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
8
|
-
|
|
8
|
+
import { tracingSrvxPlugins } from "#nitro/virtual/tracing";
|
|
9
|
+
const _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
|
|
10
|
+
const port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
|
|
9
11
|
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
10
12
|
const cert = process.env.NITRO_SSL_CERT;
|
|
11
13
|
const key = process.env.NITRO_SSL_KEY;
|
|
12
|
-
|
|
14
|
+
|
|
13
15
|
const nitroApp = useNitroApp();
|
|
14
16
|
let _fetch = nitroApp.fetch;
|
|
15
17
|
if (import.meta._websocket) {
|
|
@@ -21,18 +23,19 @@ if (import.meta._websocket) {
|
|
|
21
23
|
return nitroApp.fetch(req);
|
|
22
24
|
};
|
|
23
25
|
}
|
|
24
|
-
serve({
|
|
26
|
+
const server = serve({
|
|
25
27
|
port,
|
|
26
28
|
hostname: host,
|
|
27
29
|
tls: cert && key ? {
|
|
28
30
|
cert,
|
|
29
31
|
key
|
|
30
32
|
} : undefined,
|
|
31
|
-
fetch: _fetch
|
|
33
|
+
fetch: _fetch,
|
|
34
|
+
plugins: [...tracingSrvxPlugins]
|
|
32
35
|
});
|
|
33
36
|
trapUnhandledErrors();
|
|
34
|
-
|
|
37
|
+
|
|
35
38
|
if (import.meta._tasks) {
|
|
36
|
-
startScheduleRunner();
|
|
39
|
+
startScheduleRunner({ waitUntil: server.waitUntil });
|
|
37
40
|
}
|
|
38
41
|
export default {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import { NodeRequest } from "srvx/node";
|
|
3
|
+
import { useNitroApp } from "nitro/app";
|
|
4
|
+
const nitroApp = useNitroApp();
|
|
5
|
+
|
|
6
|
+
export default async function handle(req) {
|
|
7
|
+
|
|
8
|
+
const request = new NodeRequest({ req });
|
|
9
|
+
return nitroApp.fetch(request);
|
|
10
|
+
}
|
|
@@ -2,13 +2,12 @@ import "#nitro/virtual/polyfills";
|
|
|
2
2
|
import { useNitroApp } from "nitro/app";
|
|
3
3
|
import { isPublicAssetURL } from "#nitro/virtual/public-assets";
|
|
4
4
|
const nitroApp = useNitroApp();
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
export default async function netlifyEdge(netlifyReq, context) {
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
const req = netlifyReq;
|
|
9
9
|
req.ip = context.ip;
|
|
10
10
|
req.runtime ??= { name: "netlify-edge" };
|
|
11
|
-
// @ts-expect-error (add to srvx types)
|
|
12
11
|
req.runtime.netlify ??= { context };
|
|
13
12
|
const url = new URL(req.url);
|
|
14
13
|
if (isPublicAssetURL(url.pathname)) {
|
|
@@ -4,7 +4,7 @@ const nitroApp = useNitroApp();
|
|
|
4
4
|
const ONE_YEAR_IN_SECONDS = 365 * 24 * 60 * 60;
|
|
5
5
|
const handler = async (req) => {
|
|
6
6
|
req.runtime ??= { name: "netlify" };
|
|
7
|
-
req.ip
|
|
7
|
+
req.ip ??= req.headers.get("x-nf-client-connection-ip") || undefined;
|
|
8
8
|
const response = await nitroApp.fetch(req);
|
|
9
9
|
const isr = (req.context?.routeRules || {})?.isr?.options;
|
|
10
10
|
if (isr) {
|
|
@@ -6,11 +6,12 @@ import { useNitroApp } from "nitro/app";
|
|
|
6
6
|
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
7
7
|
import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
|
|
8
8
|
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
9
|
-
const
|
|
9
|
+
const _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
|
|
10
|
+
const port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
|
|
10
11
|
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
11
12
|
const cert = process.env.NITRO_SSL_CERT;
|
|
12
13
|
const key = process.env.NITRO_SSL_KEY;
|
|
13
|
-
|
|
14
|
+
|
|
14
15
|
const clusterId = cluster.isWorker && process.env.WORKER_ID;
|
|
15
16
|
if (clusterId) {
|
|
16
17
|
console.log(`Worker #${clusterId} started`);
|
|
@@ -46,8 +47,8 @@ if (import.meta._websocket) {
|
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
trapUnhandledErrors();
|
|
49
|
-
|
|
50
|
+
|
|
50
51
|
if (import.meta._tasks) {
|
|
51
|
-
startScheduleRunner();
|
|
52
|
+
startScheduleRunner({ waitUntil: server.waitUntil });
|
|
52
53
|
}
|
|
53
54
|
export default {};
|
|
@@ -8,7 +8,7 @@ const nitroApp = useNitroApp();
|
|
|
8
8
|
export const middleware = toNodeHandler(nitroApp.fetch);
|
|
9
9
|
const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
|
|
10
10
|
export const handleUpgrade = ws?.handleUpgrade;
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
if (import.meta._tasks) {
|
|
13
13
|
startScheduleRunner();
|
|
14
14
|
}
|
|
@@ -5,11 +5,13 @@ import { useNitroApp } from "nitro/app";
|
|
|
5
5
|
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
6
6
|
import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
|
|
7
7
|
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
8
|
-
|
|
8
|
+
import { tracingSrvxPlugins } from "#nitro/virtual/tracing";
|
|
9
|
+
const _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
|
|
10
|
+
const port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
|
|
9
11
|
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
10
12
|
const cert = process.env.NITRO_SSL_CERT;
|
|
11
13
|
const key = process.env.NITRO_SSL_KEY;
|
|
12
|
-
|
|
14
|
+
|
|
13
15
|
const nitroApp = useNitroApp();
|
|
14
16
|
const server = serve({
|
|
15
17
|
port,
|
|
@@ -18,7 +20,8 @@ const server = serve({
|
|
|
18
20
|
cert,
|
|
19
21
|
key
|
|
20
22
|
} : undefined,
|
|
21
|
-
fetch: nitroApp.fetch
|
|
23
|
+
fetch: nitroApp.fetch,
|
|
24
|
+
plugins: [...tracingSrvxPlugins]
|
|
22
25
|
});
|
|
23
26
|
if (import.meta._websocket) {
|
|
24
27
|
const { handleUpgrade } = wsAdapter({ resolve: resolveWebsocketHooks });
|
|
@@ -39,8 +42,8 @@ if (import.meta._websocket) {
|
|
|
39
42
|
});
|
|
40
43
|
}
|
|
41
44
|
trapUnhandledErrors();
|
|
42
|
-
|
|
45
|
+
|
|
43
46
|
if (import.meta._tasks) {
|
|
44
|
-
startScheduleRunner();
|
|
47
|
+
startScheduleRunner({ waitUntil: server.waitUntil });
|
|
45
48
|
}
|
|
46
49
|
export default {};
|
|
@@ -8,9 +8,8 @@ export const handler = async function(event, context) {
|
|
|
8
8
|
headers: event.headers,
|
|
9
9
|
body: event.body
|
|
10
10
|
});
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
req.runtime ??= { name: "stormkit" };
|
|
13
|
-
// @ts-expect-error (add to srvx types)
|
|
14
13
|
req.runtime.stormkit ??= {
|
|
15
14
|
event,
|
|
16
15
|
context
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { timingSafeEqual } from "node:crypto";
|
|
2
|
+
import { defineHandler, HTTPError } from "nitro/h3";
|
|
3
|
+
import { runCronTasks } from "#nitro/runtime/task";
|
|
4
|
+
export default defineHandler(async (event) => {
|
|
5
|
+
|
|
6
|
+
const cronSecret = process.env.CRON_SECRET;
|
|
7
|
+
if (cronSecret) {
|
|
8
|
+
const authHeader = event.req.headers.get("authorization") || "";
|
|
9
|
+
const expected = `Bearer ${cronSecret}`;
|
|
10
|
+
const a = Buffer.from(authHeader);
|
|
11
|
+
const b = Buffer.from(expected);
|
|
12
|
+
if (a.length !== b.length || !timingSafeEqual(a, b)) {
|
|
13
|
+
throw new HTTPError("Unauthorized", { status: 401 });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const cron = event.req.headers.get("x-vercel-cron-schedule");
|
|
17
|
+
if (!cron) {
|
|
18
|
+
throw new HTTPError("Missing x-vercel-cron-schedule header", { status: 400 });
|
|
19
|
+
}
|
|
20
|
+
await runCronTasks(cron, {
|
|
21
|
+
context: { waitUntil: event.req.waitUntil },
|
|
22
|
+
payload: { scheduledTime: Date.now() }
|
|
23
|
+
});
|
|
24
|
+
return { success: true };
|
|
25
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { handleCallback, send } from "@vercel/queue";
|
|
2
|
+
import { defineHandler } from "nitro";
|
|
3
|
+
import { useNitroApp, useNitroHooks } from "nitro/app";
|
|
4
|
+
export default defineHandler((event) => {
|
|
5
|
+
return handleCallback(async (message, metadata) => {
|
|
6
|
+
try {
|
|
7
|
+
await useNitroHooks().callHook("vercel:queue", {
|
|
8
|
+
message,
|
|
9
|
+
metadata,
|
|
10
|
+
send
|
|
11
|
+
});
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error("[vercel:queue]", error);
|
|
14
|
+
useNitroApp().captureError?.(error, {
|
|
15
|
+
event,
|
|
16
|
+
tags: ["vercel:queue"]
|
|
17
|
+
});
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
})(event.req);
|
|
21
|
+
});
|
|
@@ -5,14 +5,14 @@ import { isrRouteRewrite } from "./isr.mjs";
|
|
|
5
5
|
const nitroApp = useNitroApp();
|
|
6
6
|
const handler = toNodeHandler(nitroApp.fetch);
|
|
7
7
|
export default function nodeHandler(req, res) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
|
|
10
10
|
let ip;
|
|
11
11
|
Object.defineProperty(req.socket, "remoteAddress", { get() {
|
|
12
12
|
const h = req.headers["x-forwarded-for"];
|
|
13
13
|
return ip ??= h?.split?.(",").shift()?.trim();
|
|
14
14
|
} });
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
const isrURL = isrRouteRewrite(req.url, req.headers["x-now-route-matches"]);
|
|
17
17
|
if (isrURL) {
|
|
18
18
|
const { routeRules } = getRouteRules("", isrURL[0]);
|
|
@@ -3,7 +3,7 @@ import { useNitroApp, getRouteRules } from "nitro/app";
|
|
|
3
3
|
import { isrRouteRewrite } from "./isr.mjs";
|
|
4
4
|
const nitroApp = useNitroApp();
|
|
5
5
|
export default { fetch(req, context) {
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
const isrURL = isrRouteRewrite(req.url, req.headers.get("x-now-route-matches"));
|
|
8
8
|
if (isrURL) {
|
|
9
9
|
const { routeRules } = getRouteRules("", isrURL[0]);
|
|
@@ -11,10 +11,8 @@ export default { fetch(req, context) {
|
|
|
11
11
|
req = new Request(new URL(isrURL[0] + (isrURL[1] ? `?${isrURL[1]}` : ""), req.url).href, req);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
req.runtime
|
|
15
|
-
|
|
16
|
-
vercel: { context }
|
|
17
|
-
};
|
|
14
|
+
req.runtime ??= { name: "vercel" };
|
|
15
|
+
req.runtime.vercel = { context };
|
|
18
16
|
let ip;
|
|
19
17
|
Object.defineProperty(req, "ip", { get() {
|
|
20
18
|
const h = req.headers.get("x-forwarded-for");
|
|
@@ -3,8 +3,8 @@ import "#nitro/virtual/polyfills";
|
|
|
3
3
|
import { useNitroApp } from "nitro/app";
|
|
4
4
|
import { hasProtocol, joinURL } from "ufo";
|
|
5
5
|
const nitroApp = useNitroApp();
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
|
|
7
|
+
|
|
8
8
|
const _handler = toPlainHandler(nitroApp.h3App);
|
|
9
9
|
async function _handleEvent(event) {
|
|
10
10
|
try {
|
|
@@ -33,9 +33,9 @@ async function _handleEvent(event) {
|
|
|
33
33
|
addEventListener("fetch", async (event) => {
|
|
34
34
|
event.respondWith(await _handleEvent(event));
|
|
35
35
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
39
|
function toBuffer(data) {
|
|
40
40
|
return new Promise((resolve, reject) => {
|
|
41
41
|
const chunks = [];
|
|
@@ -52,20 +52,20 @@ function toBuffer(data) {
|
|
|
52
52
|
})).catch(reject);
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
if (!Headers.prototype.entries) {
|
|
57
57
|
// @ts-ignore
|
|
58
58
|
Headers.prototype.entries = function() {
|
|
59
59
|
return [...this];
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
if (!URL.prototype.pathname) {
|
|
64
64
|
Object.defineProperty(URL.prototype, "pathname", { get() {
|
|
65
65
|
return this.path || "/";
|
|
66
66
|
} });
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
const _URL = globalThis.URL;
|
|
70
70
|
globalThis.URL = class URL extends _URL {
|
|
71
71
|
constructor(url, base) {
|
|
@@ -76,7 +76,7 @@ globalThis.URL = class URL extends _URL {
|
|
|
76
76
|
super(joinURL(base, url));
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
const _Response = globalThis.Response;
|
|
81
81
|
globalThis.Response = class Response extends _Response {
|
|
82
82
|
_body;
|
|
@@ -85,7 +85,7 @@ globalThis.Response = class Response extends _Response {
|
|
|
85
85
|
this._body = body;
|
|
86
86
|
}
|
|
87
87
|
get body() {
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
return this._body;
|
|
90
90
|
}
|
|
91
91
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { H3Core, toRequest } from "h3";
|
|
2
2
|
import { HookableCore } from "hookable";
|
|
3
3
|
import { nitroAsyncContext } from "./context.mjs";
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import errorHandler from "#nitro/virtual/error-handler";
|
|
6
6
|
import { plugins } from "#nitro/virtual/plugins";
|
|
7
7
|
import { findRoute, findRouteRules, globalMiddleware, findRoutedMiddleware } from "#nitro/virtual/routing";
|
|
@@ -42,7 +42,7 @@ export function serverFetch(resource, init, context) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
export async function resolveWebsocketHooks(req) {
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
const hooks = (await serverFetch(req)).crossws;
|
|
47
47
|
return hooks || {};
|
|
48
48
|
}
|
|
@@ -51,7 +51,7 @@ export function fetch(resource, init, context) {
|
|
|
51
51
|
return serverFetch(resource, init, context);
|
|
52
52
|
}
|
|
53
53
|
resource = resource._request || resource;
|
|
54
|
-
return fetch(resource, init);
|
|
54
|
+
return globalThis.fetch(resource, init);
|
|
55
55
|
}
|
|
56
56
|
function createNitroApp() {
|
|
57
57
|
const hooks = hasHooks ? new HookableCore() : undefined;
|
|
@@ -99,7 +99,7 @@ function createNitroApp() {
|
|
|
99
99
|
req.context.nitro = req.context.nitro || { errors: [] };
|
|
100
100
|
return h3App.fetch(req);
|
|
101
101
|
};
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
if (import.meta._asyncContext) {
|
|
104
104
|
const originalHandler = appHandler;
|
|
105
105
|
appHandler = (req) => {
|
|
@@ -127,9 +127,9 @@ function initNitroPlugins(app) {
|
|
|
127
127
|
return app;
|
|
128
128
|
}
|
|
129
129
|
function createH3App(config) {
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
const h3App = new H3Core(config);
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
hasRoutes && (h3App["~findRoute"] = (event) => findRoute(event.req.method, event.url.pathname));
|
|
134
134
|
hasGlobalMiddleware && h3App["~middleware"].push(...globalMiddleware);
|
|
135
135
|
if (hasRouteRules || hasRoutedMiddleware) {
|
|
@@ -166,21 +166,21 @@ export function getRouteRules(method, pathname) {
|
|
|
166
166
|
const currentRule = routeRules[rule.name];
|
|
167
167
|
if (currentRule) {
|
|
168
168
|
if (rule.options === false) {
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
delete routeRules[rule.name];
|
|
171
171
|
continue;
|
|
172
172
|
}
|
|
173
173
|
if (typeof currentRule.options === "object" && typeof rule.options === "object") {
|
|
174
|
-
|
|
174
|
+
|
|
175
175
|
currentRule.options = {
|
|
176
176
|
...currentRule.options,
|
|
177
177
|
...rule.options
|
|
178
178
|
};
|
|
179
179
|
} else {
|
|
180
|
-
|
|
180
|
+
|
|
181
181
|
currentRule.options = rule.options;
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
|
|
184
184
|
currentRule.route = rule.route;
|
|
185
185
|
currentRule.params = {
|
|
186
186
|
...currentRule.params,
|
|
@@ -195,7 +195,8 @@ export function getRouteRules(method, pathname) {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
const middleware = [];
|
|
198
|
-
|
|
198
|
+
const orderedRules = Object.values(routeRules).sort((a, b) => (a.handler?.order || 0) - (b.handler?.order || 0));
|
|
199
|
+
for (const rule of orderedRules) {
|
|
199
200
|
if (rule.options === false || !rule.handler) {
|
|
200
201
|
continue;
|
|
201
202
|
}
|
|
@@ -4,8 +4,4 @@ export declare function defineCachedFunction<
|
|
|
4
4
|
T,
|
|
5
5
|
ArgsT extends unknown[] = any[]
|
|
6
6
|
>(fn: (...args: ArgsT) => T | Promise<T>, opts?: CacheOptions<T, ArgsT>): (...args: ArgsT) => Promise<T>;
|
|
7
|
-
export declare function cachedFunction<
|
|
8
|
-
T,
|
|
9
|
-
ArgsT extends unknown[] = any[]
|
|
10
|
-
>(fn: (...args: ArgsT) => T | Promise<T>, opts?: CacheOptions<T>): (...args: ArgsT) => Promise<T | undefined>;
|
|
11
7
|
export declare function defineCachedHandler(handler: EventHandler, opts?: CachedEventHandlerOptions): EventHandler;
|