@depup/nitro 3.0.260311-beta-depup.0
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 +27 -0
- package/README.md +32 -0
- package/changes.json +14 -0
- package/dist/THIRD-PARTY-LICENSES.md +1646 -0
- package/dist/_build/common.mjs +29361 -0
- package/dist/_build/rolldown.mjs +173 -0
- package/dist/_build/rollup.mjs +194 -0
- package/dist/_build/vite.build.mjs +18 -0
- package/dist/_chunks/nitro.mjs +1159 -0
- package/dist/_chunks/nitro2.mjs +102 -0
- package/dist/_chunks/nitro3.mjs +129 -0
- package/dist/_chunks/utils.mjs +272 -0
- package/dist/_common.mjs +35 -0
- package/dist/_dev.d.mts +12 -0
- package/dist/_dev.mjs +519 -0
- package/dist/_libs/_.mjs +3 -0
- package/dist/_libs/_2.mjs +2 -0
- package/dist/_libs/_3.mjs +3 -0
- package/dist/_libs/_4.mjs +2 -0
- package/dist/_libs/_5.mjs +3 -0
- package/dist/_libs/_6.mjs +4 -0
- package/dist/_libs/_7.mjs +5 -0
- package/dist/_libs/c12+rc9.mjs +812 -0
- package/dist/_libs/c12+readdirp+chokidar.d.mts +230 -0
- package/dist/_libs/citty.mjs +361 -0
- package/dist/_libs/commondir+is-reference.mjs +1311 -0
- package/dist/_libs/compatx.d.mts +47 -0
- package/dist/_libs/compatx.mjs +45 -0
- package/dist/_libs/esbuild.d.mts +20 -0
- package/dist/_libs/escape-string-regexp.mjs +7 -0
- package/dist/_libs/estree+pluginutils.d.mts +241 -0
- package/dist/_libs/estree-walker.mjs +184 -0
- package/dist/_libs/exsolve.d.mts +1 -0
- package/dist/_libs/hasown+resolve+deepmerge.mjs +1949 -0
- package/dist/_libs/httpxy.d.mts +82 -0
- package/dist/_libs/httpxy.mjs +671 -0
- package/dist/_libs/js-tokens.d.mts +1 -0
- package/dist/_libs/klona.mjs +37 -0
- package/dist/_libs/magic-string.d.mts +220 -0
- package/dist/_libs/mlly.d.mts +57 -0
- package/dist/_libs/nypm+tinyexec.mjs +845 -0
- package/dist/_libs/perfect-debounce.mjs +88 -0
- package/dist/_libs/pkg-types.d.mts +23 -0
- package/dist/_libs/plugin-alias.mjs +64 -0
- package/dist/_libs/plugin-inject.mjs +131 -0
- package/dist/_libs/plugin-json.mjs +34 -0
- package/dist/_libs/pluginutils.mjs +646 -0
- package/dist/_libs/readdirp+chokidar.mjs +1606 -0
- package/dist/_libs/remapping.mjs +115 -0
- package/dist/_libs/resolve-uri+gen-mapping.mjs +442 -0
- package/dist/_libs/rou3.d.mts +44 -0
- package/dist/_libs/rou3.mjs +496 -0
- package/dist/_libs/std-env.d.mts +12 -0
- package/dist/_libs/strip-literal.d.mts +1 -0
- package/dist/_libs/tsconfck.mjs +813 -0
- package/dist/_libs/ultrahtml.mjs +127 -0
- package/dist/_libs/unimport+unplugin.mjs +1684 -0
- package/dist/_libs/unplugin+unimport.d.mts +423 -0
- package/dist/_libs/unwasm.d.mts +29 -0
- package/dist/_presets.mjs +1759 -0
- package/dist/builder.d.mts +64 -0
- package/dist/builder.mjs +15 -0
- package/dist/cli/_chunks/build.mjs +47 -0
- package/dist/cli/_chunks/common.mjs +14 -0
- package/dist/cli/_chunks/deploy.mjs +40 -0
- package/dist/cli/_chunks/dev.mjs +62 -0
- package/dist/cli/_chunks/docs.mjs +30 -0
- package/dist/cli/_chunks/list.mjs +25 -0
- package/dist/cli/_chunks/prepare.mjs +17 -0
- package/dist/cli/_chunks/preview.mjs +51 -0
- package/dist/cli/_chunks/run.mjs +53 -0
- package/dist/cli/_chunks/task.mjs +14 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +22 -0
- package/dist/node_modules/@poppinss/colors/build/index.js +139 -0
- package/dist/node_modules/@poppinss/colors/package.json +118 -0
- package/dist/node_modules/@poppinss/dumper/build/chunk-26HALFTP.js +602 -0
- package/dist/node_modules/@poppinss/dumper/build/formatters/console/main.js +441 -0
- package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +725 -0
- package/dist/node_modules/@poppinss/dumper/package.json +122 -0
- package/dist/node_modules/@poppinss/exception/build/index.js +44 -0
- package/dist/node_modules/@poppinss/exception/package.json +109 -0
- package/dist/node_modules/@sindresorhus/is/distribution/index.js +1354 -0
- package/dist/node_modules/@sindresorhus/is/distribution/utilities.js +3 -0
- package/dist/node_modules/@sindresorhus/is/package.json +81 -0
- package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -0
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -0
- package/dist/node_modules/@speed-highlight/core/package.json +94 -0
- package/dist/node_modules/cookie-es/dist/index.mjs +262 -0
- package/dist/node_modules/cookie-es/package.json +37 -0
- package/dist/node_modules/croner/dist/croner.js +1 -0
- package/dist/node_modules/croner/package.json +73 -0
- package/dist/node_modules/defu/dist/defu.mjs +69 -0
- package/dist/node_modules/defu/package.json +43 -0
- package/dist/node_modules/destr/dist/index.mjs +72 -0
- package/dist/node_modules/destr/package.json +47 -0
- package/dist/node_modules/error-stack-parser-es/dist/index.mjs +38 -0
- package/dist/node_modules/error-stack-parser-es/dist/lite.mjs +167 -0
- package/dist/node_modules/error-stack-parser-es/package.json +83 -0
- package/dist/node_modules/get-port-please/dist/index.mjs +430 -0
- package/dist/node_modules/get-port-please/package.json +39 -0
- package/dist/node_modules/kleur/index.mjs +110 -0
- package/dist/node_modules/kleur/package.json +51 -0
- package/dist/node_modules/rendu/dist/index.mjs +380 -0
- package/dist/node_modules/rendu/package.json +47 -0
- package/dist/node_modules/scule/dist/index.mjs +80 -0
- package/dist/node_modules/scule/package.json +43 -0
- package/dist/node_modules/source-map/lib/array-set.js +100 -0
- package/dist/node_modules/source-map/lib/base64-vlq.js +94 -0
- package/dist/node_modules/source-map/lib/base64.js +19 -0
- package/dist/node_modules/source-map/lib/binary-search.js +113 -0
- package/dist/node_modules/source-map/lib/mapping-list.js +83 -0
- package/dist/node_modules/source-map/lib/mappings.wasm +0 -0
- package/dist/node_modules/source-map/lib/read-wasm.js +27 -0
- package/dist/node_modules/source-map/lib/source-map-consumer.js +1081 -0
- package/dist/node_modules/source-map/lib/source-map-generator.js +439 -0
- package/dist/node_modules/source-map/lib/source-node.js +430 -0
- package/dist/node_modules/source-map/lib/url.js +13 -0
- package/dist/node_modules/source-map/lib/util.js +444 -0
- package/dist/node_modules/source-map/lib/wasm.js +138 -0
- package/dist/node_modules/source-map/package.json +79 -0
- package/dist/node_modules/source-map/source-map.js +10 -0
- package/dist/node_modules/supports-color/index.js +202 -0
- package/dist/node_modules/supports-color/package.json +64 -0
- package/dist/node_modules/ufo/dist/index.mjs +645 -0
- package/dist/node_modules/ufo/package.json +48 -0
- package/dist/node_modules/unctx/dist/index.mjs +131 -0
- package/dist/node_modules/unctx/package.json +67 -0
- package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
- package/dist/node_modules/youch/build/index.js +212 -0
- package/dist/node_modules/youch/build/public/error_cause/style.css +5 -0
- package/dist/node_modules/youch/build/public/error_info/script.js +13 -0
- package/dist/node_modules/youch/build/public/error_info/style.css +145 -0
- package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
- package/dist/node_modules/youch/build/public/error_stack/script.js +72 -0
- package/dist/node_modules/youch/build/public/error_stack/style.css +219 -0
- package/dist/node_modules/youch/build/public/error_stack_source/style.css +123 -0
- package/dist/node_modules/youch/build/public/header/script.js +14 -0
- package/dist/node_modules/youch/build/public/header/style.css +56 -0
- package/dist/node_modules/youch/build/public/layout/script.js +12 -0
- package/dist/node_modules/youch/build/public/layout/style.css +435 -0
- 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 +135 -0
- package/dist/node_modules/youch-core/build/index.js +316 -0
- package/dist/node_modules/youch-core/package.json +124 -0
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +20 -0
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +15 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +23 -0
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +14 -0
- package/dist/presets/aws-lambda/runtime/_utils.mjs +116 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +31 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +13 -0
- package/dist/presets/azure/runtime/_utils.mjs +50 -0
- package/dist/presets/azure/runtime/azure-swa.mjs +30 -0
- package/dist/presets/bun/runtime/bun.mjs +40 -0
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +87 -0
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +72 -0
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +17 -0
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +39 -0
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +96 -0
- package/dist/presets/cloudflare/runtime/shims/workers.dev.mjs +27 -0
- package/dist/presets/deno/runtime/deno-deploy.mjs +19 -0
- package/dist/presets/deno/runtime/deno-server.mjs +39 -0
- package/dist/presets/netlify/runtime/netlify-edge.mjs +20 -0
- package/dist/presets/netlify/runtime/netlify.mjs +20 -0
- package/dist/presets/node/runtime/node-cluster.mjs +54 -0
- package/dist/presets/node/runtime/node-middleware.mjs +14 -0
- package/dist/presets/node/runtime/node-server.mjs +47 -0
- package/dist/presets/standard/runtime/server.mjs +4 -0
- package/dist/presets/stormkit/runtime/stormkit.mjs +27 -0
- package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
- package/dist/presets/vercel/runtime/isr.mjs +19 -0
- package/dist/presets/vercel/runtime/vercel.node.mjs +24 -0
- package/dist/presets/vercel/runtime/vercel.web.mjs +23 -0
- package/dist/presets/winterjs/runtime/winterjs.mjs +91 -0
- package/dist/presets/zeabur/runtime/zeabur.mjs +4 -0
- package/dist/presets/zephyr/runtime/server.mjs +3 -0
- package/dist/runtime/app.d.mts +1 -0
- package/dist/runtime/app.mjs +1 -0
- package/dist/runtime/cache.d.mts +1 -0
- package/dist/runtime/cache.mjs +1 -0
- package/dist/runtime/config.d.mts +3 -0
- package/dist/runtime/config.mjs +4 -0
- package/dist/runtime/context.d.mts +1 -0
- package/dist/runtime/context.mjs +1 -0
- package/dist/runtime/database.d.mts +1 -0
- package/dist/runtime/database.mjs +1 -0
- package/dist/runtime/internal/app.d.mts +16 -0
- package/dist/runtime/internal/app.mjs +208 -0
- package/dist/runtime/internal/cache.d.mts +7 -0
- package/dist/runtime/internal/cache.mjs +41 -0
- package/dist/runtime/internal/context.d.mts +14 -0
- package/dist/runtime/internal/context.mjs +24 -0
- package/dist/runtime/internal/database.d.mts +2 -0
- package/dist/runtime/internal/database.mjs +12 -0
- package/dist/runtime/internal/empty.mjs +0 -0
- package/dist/runtime/internal/error/dev.d.mts +10 -0
- package/dist/runtime/internal/error/dev.mjs +121 -0
- package/dist/runtime/internal/error/hooks.d.mts +1 -0
- package/dist/runtime/internal/error/hooks.mjs +9 -0
- package/dist/runtime/internal/error/prod.d.mts +6 -0
- package/dist/runtime/internal/error/prod.mjs +40 -0
- package/dist/runtime/internal/error/utils.d.mts +8 -0
- package/dist/runtime/internal/error/utils.mjs +3 -0
- package/dist/runtime/internal/meta.d.mts +2 -0
- package/dist/runtime/internal/meta.mjs +3 -0
- package/dist/runtime/internal/plugin.d.mts +3 -0
- package/dist/runtime/internal/plugin.mjs +4 -0
- package/dist/runtime/internal/route-rules.d.mts +9 -0
- package/dist/runtime/internal/route-rules.mjs +72 -0
- package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -0
- package/dist/runtime/internal/routes/dev-tasks.mjs +25 -0
- package/dist/runtime/internal/routes/openapi.d.mts +3 -0
- package/dist/runtime/internal/routes/openapi.mjs +94 -0
- package/dist/runtime/internal/routes/renderer-template.d.mts +2 -0
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +3 -0
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +19 -0
- package/dist/runtime/internal/routes/renderer-template.mjs +4 -0
- package/dist/runtime/internal/routes/scalar.d.mts +3 -0
- package/dist/runtime/internal/routes/scalar.mjs +193 -0
- package/dist/runtime/internal/routes/swagger.d.mts +3 -0
- package/dist/runtime/internal/routes/swagger.mjs +42 -0
- package/dist/runtime/internal/runtime-config.d.mts +9 -0
- package/dist/runtime/internal/runtime-config.mjs +54 -0
- package/dist/runtime/internal/static.d.mts +3 -0
- package/dist/runtime/internal/static.mjs +67 -0
- package/dist/runtime/internal/storage.d.mts +2 -0
- package/dist/runtime/internal/storage.mjs +6 -0
- package/dist/runtime/internal/task.d.mts +19 -0
- package/dist/runtime/internal/task.mjs +69 -0
- package/dist/runtime/internal/vite/dev-entry.mjs +18 -0
- package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
- package/dist/runtime/internal/vite/ssr-renderer.mjs +6 -0
- package/dist/runtime/meta.d.mts +5 -0
- package/dist/runtime/meta.mjs +27 -0
- package/dist/runtime/nitro.d.mts +11 -0
- package/dist/runtime/nitro.mjs +34 -0
- package/dist/runtime/runtime-config.d.mts +1 -0
- package/dist/runtime/runtime-config.mjs +1 -0
- package/dist/runtime/storage.d.mts +1 -0
- package/dist/runtime/storage.mjs +1 -0
- package/dist/runtime/task.d.mts +1 -0
- package/dist/runtime/task.mjs +1 -0
- package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
- package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
- package/dist/runtime/virtual/database.d.mts +8 -0
- package/dist/runtime/virtual/database.mjs +2 -0
- package/dist/runtime/virtual/error-handler.d.mts +6 -0
- package/dist/runtime/virtual/error-handler.mjs +9 -0
- package/dist/runtime/virtual/feature-flags.d.mts +7 -0
- package/dist/runtime/virtual/feature-flags.mjs +7 -0
- package/dist/runtime/virtual/plugins.d.mts +3 -0
- package/dist/runtime/virtual/plugins.mjs +2 -0
- package/dist/runtime/virtual/polyfills.d.mts +3 -0
- package/dist/runtime/virtual/polyfills.mjs +2 -0
- package/dist/runtime/virtual/public-assets.d.mts +9 -0
- package/dist/runtime/virtual/public-assets.mjs +8 -0
- package/dist/runtime/virtual/renderer-template.d.mts +4 -0
- package/dist/runtime/virtual/renderer-template.mjs +7 -0
- package/dist/runtime/virtual/routing-meta.d.mts +7 -0
- package/dist/runtime/virtual/routing-meta.mjs +2 -0
- package/dist/runtime/virtual/routing.d.mts +8 -0
- package/dist/runtime/virtual/routing.mjs +11 -0
- package/dist/runtime/virtual/runtime-config.d.mts +3 -0
- package/dist/runtime/virtual/runtime-config.mjs +5 -0
- package/dist/runtime/virtual/server-assets.d.mts +7 -0
- package/dist/runtime/virtual/server-assets.mjs +12 -0
- package/dist/runtime/virtual/storage.d.mts +3 -0
- package/dist/runtime/virtual/storage.mjs +5 -0
- package/dist/runtime/virtual/tasks.d.mts +10 -0
- package/dist/runtime/virtual/tasks.mjs +3 -0
- package/dist/runtime/vite.d.mts +8 -0
- package/dist/runtime/vite.mjs +9 -0
- package/dist/types/index.d.mts +3010 -0
- package/dist/types/index.mjs +1 -0
- package/dist/vite.d.mts +52 -0
- package/dist/vite.mjs +740 -0
- package/lib/h3.d.mts +1 -0
- package/lib/h3.mjs +1 -0
- package/lib/tsconfig.json +27 -0
- package/lib/vite.types.d.mts +26 -0
- package/lib/vite.types.mjs +2 -0
- package/package.json +256 -0
- package/skills/nitro/SKILL.md +10 -0
- package/skills/nitro/docs/TOC.md +83 -0
- package/skills/nitro/docs/_navigation.json +679 -0
- package/skills/nitro/docs/config/index.md +1147 -0
- package/skills/nitro/docs/deploy/index.md +64 -0
- package/skills/nitro/docs/deploy/providers/alwaysdata.md +50 -0
- package/skills/nitro/docs/deploy/providers/aws-amplify.md +81 -0
- package/skills/nitro/docs/deploy/providers/aws.md +47 -0
- package/skills/nitro/docs/deploy/providers/azure.md +72 -0
- package/skills/nitro/docs/deploy/providers/cleavr.md +33 -0
- package/skills/nitro/docs/deploy/providers/cloudflare.md +375 -0
- package/skills/nitro/docs/deploy/providers/deno-deploy.md +66 -0
- package/skills/nitro/docs/deploy/providers/digitalocean.md +46 -0
- package/skills/nitro/docs/deploy/providers/firebase.md +32 -0
- package/skills/nitro/docs/deploy/providers/flightcontrol.md +67 -0
- package/skills/nitro/docs/deploy/providers/genezio.md +67 -0
- package/skills/nitro/docs/deploy/providers/github-pages.md +68 -0
- package/skills/nitro/docs/deploy/providers/gitlab-pages.md +37 -0
- package/skills/nitro/docs/deploy/providers/heroku.md +84 -0
- package/skills/nitro/docs/deploy/providers/iis.md +38 -0
- package/skills/nitro/docs/deploy/providers/koyeb.md +109 -0
- package/skills/nitro/docs/deploy/providers/netlify.md +47 -0
- package/skills/nitro/docs/deploy/providers/platform-sh.md +37 -0
- package/skills/nitro/docs/deploy/providers/render.md +37 -0
- package/skills/nitro/docs/deploy/providers/stormkit.md +24 -0
- package/skills/nitro/docs/deploy/providers/vercel.md +179 -0
- package/skills/nitro/docs/deploy/providers/zeabur.md +19 -0
- package/skills/nitro/docs/deploy/providers/zephyr.md +99 -0
- package/skills/nitro/docs/deploy/providers/zerops.md +102 -0
- package/skills/nitro/docs/deploy/runtimes/bun.md +15 -0
- package/skills/nitro/docs/deploy/runtimes/deno.md +19 -0
- package/skills/nitro/docs/deploy/runtimes/node.md +63 -0
- package/skills/nitro/docs/docs/assets.md +166 -0
- package/skills/nitro/docs/docs/cache.md +408 -0
- package/skills/nitro/docs/docs/configuration.md +256 -0
- package/skills/nitro/docs/docs/database.md +185 -0
- package/skills/nitro/docs/docs/index.md +56 -0
- package/skills/nitro/docs/docs/lifecycle.md +204 -0
- package/skills/nitro/docs/docs/migration.md +215 -0
- package/skills/nitro/docs/docs/nightly.md +31 -0
- package/skills/nitro/docs/docs/plugins.md +164 -0
- package/skills/nitro/docs/docs/quick-start.md +110 -0
- package/skills/nitro/docs/docs/renderer.md +322 -0
- package/skills/nitro/docs/docs/routing.md +711 -0
- package/skills/nitro/docs/docs/server-entry.md +239 -0
- package/skills/nitro/docs/docs/storage.md +261 -0
- package/skills/nitro/docs/docs/tasks.md +277 -0
- package/skills/nitro/docs/examples/api-routes.md +145 -0
- package/skills/nitro/docs/examples/auto-imports.md +93 -0
- package/skills/nitro/docs/examples/cached-handler.md +81 -0
- package/skills/nitro/docs/examples/custom-error-handler.md +98 -0
- package/skills/nitro/docs/examples/database.md +157 -0
- package/skills/nitro/docs/examples/elysia.md +70 -0
- package/skills/nitro/docs/examples/express.md +78 -0
- package/skills/nitro/docs/examples/fastify.md +79 -0
- package/skills/nitro/docs/examples/hello-world.md +68 -0
- package/skills/nitro/docs/examples/hono.md +74 -0
- package/skills/nitro/docs/examples/import-alias.md +100 -0
- package/skills/nitro/docs/examples/index.md +3 -0
- package/skills/nitro/docs/examples/middleware.md +91 -0
- package/skills/nitro/docs/examples/mono-jsx.md +68 -0
- package/skills/nitro/docs/examples/nano-jsx.md +70 -0
- package/skills/nitro/docs/examples/plugins.md +91 -0
- package/skills/nitro/docs/examples/renderer.md +113 -0
- package/skills/nitro/docs/examples/runtime-config.md +97 -0
- package/skills/nitro/docs/examples/server-fetch.md +87 -0
- package/skills/nitro/docs/examples/shiki.md +198 -0
- package/skills/nitro/docs/examples/virtual-routes.md +74 -0
- package/skills/nitro/docs/examples/vite-nitro-plugin.md +79 -0
- package/skills/nitro/docs/examples/vite-rsc.md +1041 -0
- package/skills/nitro/docs/examples/vite-ssr-html.md +217 -0
- package/skills/nitro/docs/examples/vite-ssr-preact.md +247 -0
- package/skills/nitro/docs/examples/vite-ssr-react.md +226 -0
- package/skills/nitro/docs/examples/vite-ssr-solid.md +256 -0
- package/skills/nitro/docs/examples/vite-ssr-tsr-react.md +442 -0
- package/skills/nitro/docs/examples/vite-ssr-tss-react.md +444 -0
- package/skills/nitro/docs/examples/vite-ssr-vue-router.md +616 -0
- package/skills/nitro/docs/examples/vite-trpc.md +335 -0
- package/skills/nitro/docs/examples/websocket.md +282 -0
- package/skills/nitro/docs/index.md +121 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { parse } from "cookie-es";
|
|
2
|
+
export function getAzureParsedCookiesFromHeaders(headers) {
|
|
3
|
+
const setCookieHeader = headers.getSetCookie();
|
|
4
|
+
if (setCookieHeader.length === 0) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
const azureCookies = [];
|
|
8
|
+
for (const setCookieStr of setCookieHeader) {
|
|
9
|
+
const setCookie = Object.entries(parse(setCookieStr));
|
|
10
|
+
if (setCookie.length === 0) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const [[key, value], ..._setCookieOptions] = setCookie;
|
|
14
|
+
const setCookieOptions = Object.fromEntries(_setCookieOptions.map(([k, v]) => [k.toLowerCase(), v]));
|
|
15
|
+
const cookieObject = {
|
|
16
|
+
name: key,
|
|
17
|
+
value,
|
|
18
|
+
domain: setCookieOptions.domain,
|
|
19
|
+
path: setCookieOptions.path,
|
|
20
|
+
expires: parseNumberOrDate(setCookieOptions.expires),
|
|
21
|
+
sameSite: setCookieOptions.samesite,
|
|
22
|
+
maxAge: parseNumber(setCookieOptions["max-age"]),
|
|
23
|
+
secure: setCookieStr.includes("Secure") ? true : undefined,
|
|
24
|
+
httpOnly: setCookieStr.includes("HttpOnly") ? true : undefined
|
|
25
|
+
};
|
|
26
|
+
azureCookies.push(cookieObject);
|
|
27
|
+
}
|
|
28
|
+
return azureCookies;
|
|
29
|
+
}
|
|
30
|
+
function parseNumberOrDate(expires) {
|
|
31
|
+
const expiresAsNumber = parseNumber(expires);
|
|
32
|
+
if (expiresAsNumber !== undefined) {
|
|
33
|
+
return expiresAsNumber;
|
|
34
|
+
}
|
|
35
|
+
// Convert to Date if possible
|
|
36
|
+
const expiresAsDate = new Date(expires);
|
|
37
|
+
if (!Number.isNaN(expiresAsDate.getTime())) {
|
|
38
|
+
return expiresAsDate;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function parseNumber(maxAge) {
|
|
42
|
+
if (!maxAge) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
// Convert to number if possible
|
|
46
|
+
const maxAgeAsNumber = Number(maxAge);
|
|
47
|
+
if (!Number.isNaN(maxAgeAsNumber)) {
|
|
48
|
+
return maxAgeAsNumber;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import { parseURL } from "ufo";
|
|
3
|
+
import { useNitroApp } from "nitro/app";
|
|
4
|
+
import { getAzureParsedCookiesFromHeaders } from "./_utils.mjs";
|
|
5
|
+
const nitroApp = useNitroApp();
|
|
6
|
+
export async function handle(context, req) {
|
|
7
|
+
let url;
|
|
8
|
+
if (req.headers["x-ms-original-url"]) {
|
|
9
|
+
// This URL has been proxied as there was no static file matching it.
|
|
10
|
+
const parsedURL = parseURL(req.headers["x-ms-original-url"]);
|
|
11
|
+
url = parsedURL.pathname + parsedURL.search;
|
|
12
|
+
} else {
|
|
13
|
+
// Because Azure SWA handles /api/* calls differently they
|
|
14
|
+
// never hit the proxy and we have to reconstitute the URL.
|
|
15
|
+
url = "/api/" + (req.params.url || "");
|
|
16
|
+
}
|
|
17
|
+
const request = new Request(url, {
|
|
18
|
+
method: req.method || undefined,
|
|
19
|
+
body: req.bufferBody ?? req.rawBody
|
|
20
|
+
});
|
|
21
|
+
const response = await nitroApp.fetch(request);
|
|
22
|
+
// (v3 - current) https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-node?tabs=typescript%2Cwindows%2Cazure-cli&pivots=nodejs-model-v3#http-response
|
|
23
|
+
// (v4) https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-node?tabs=typescript%2Cwindows%2Cazure-cli&pivots=nodejs-model-v4#http-response
|
|
24
|
+
context.res = {
|
|
25
|
+
status: response.status,
|
|
26
|
+
body: response.body,
|
|
27
|
+
cookies: getAzureParsedCookiesFromHeaders(response.headers),
|
|
28
|
+
headers: Object.fromEntries([...response.headers.entries()].filter(([key]) => key !== "set-cookie"))
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import { serve } from "srvx/bun";
|
|
3
|
+
import wsAdapter from "crossws/adapters/bun";
|
|
4
|
+
import { useNitroApp } from "nitro/app";
|
|
5
|
+
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
6
|
+
import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
|
|
7
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
8
|
+
const _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
|
|
9
|
+
const port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
|
|
10
|
+
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
11
|
+
const cert = process.env.NITRO_SSL_CERT;
|
|
12
|
+
const key = process.env.NITRO_SSL_KEY;
|
|
13
|
+
// const socketPath = process.env.NITRO_UNIX_SOCKET; // TODO
|
|
14
|
+
const nitroApp = useNitroApp();
|
|
15
|
+
let _fetch = nitroApp.fetch;
|
|
16
|
+
const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
|
|
17
|
+
if (import.meta._websocket) {
|
|
18
|
+
_fetch = (req) => {
|
|
19
|
+
if (req.headers.get("upgrade") === "websocket") {
|
|
20
|
+
return ws.handleUpgrade(req, req.runtime.bun.server);
|
|
21
|
+
}
|
|
22
|
+
return nitroApp.fetch(req);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const server = serve({
|
|
26
|
+
port,
|
|
27
|
+
hostname: host,
|
|
28
|
+
tls: cert && key ? {
|
|
29
|
+
cert,
|
|
30
|
+
key
|
|
31
|
+
} : undefined,
|
|
32
|
+
fetch: _fetch,
|
|
33
|
+
bun: { websocket: import.meta._websocket ? ws?.websocket : undefined }
|
|
34
|
+
});
|
|
35
|
+
trapUnhandledErrors();
|
|
36
|
+
// Scheduled tasks
|
|
37
|
+
if (import.meta._tasks) {
|
|
38
|
+
startScheduleRunner({ waitUntil: server.waitUntil });
|
|
39
|
+
}
|
|
40
|
+
export default {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import { runCronTasks } from "#nitro/runtime/task";
|
|
3
|
+
import { useNitroApp, useNitroHooks } from "nitro/app";
|
|
4
|
+
export function createHandler(hooks) {
|
|
5
|
+
const nitroApp = useNitroApp();
|
|
6
|
+
const nitroHooks = useNitroHooks();
|
|
7
|
+
return {
|
|
8
|
+
async fetch(request, env, context) {
|
|
9
|
+
globalThis.__env__ = env;
|
|
10
|
+
augmentReq(request, {
|
|
11
|
+
env,
|
|
12
|
+
context
|
|
13
|
+
});
|
|
14
|
+
const ctxExt = {};
|
|
15
|
+
const url = new URL(request.url);
|
|
16
|
+
// Preset-specific logic
|
|
17
|
+
if (hooks.fetch) {
|
|
18
|
+
const res = await hooks.fetch(request, env, context, url, ctxExt);
|
|
19
|
+
if (res) {
|
|
20
|
+
return res;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return await nitroApp.fetch(request);
|
|
24
|
+
},
|
|
25
|
+
scheduled(controller, env, context) {
|
|
26
|
+
globalThis.__env__ = env;
|
|
27
|
+
context.waitUntil(nitroHooks.callHook("cloudflare:scheduled", {
|
|
28
|
+
controller,
|
|
29
|
+
env,
|
|
30
|
+
context
|
|
31
|
+
}) || Promise.resolve());
|
|
32
|
+
if (import.meta._tasks) {
|
|
33
|
+
context.waitUntil(runCronTasks(controller.cron, {
|
|
34
|
+
context: { cloudflare: {
|
|
35
|
+
env,
|
|
36
|
+
context
|
|
37
|
+
} },
|
|
38
|
+
payload: {}
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
email(message, env, context) {
|
|
43
|
+
globalThis.__env__ = env;
|
|
44
|
+
context.waitUntil(nitroHooks.callHook("cloudflare:email", {
|
|
45
|
+
message,
|
|
46
|
+
event: message,
|
|
47
|
+
env,
|
|
48
|
+
context
|
|
49
|
+
}) || Promise.resolve());
|
|
50
|
+
},
|
|
51
|
+
queue(batch, env, context) {
|
|
52
|
+
globalThis.__env__ = env;
|
|
53
|
+
context.waitUntil(nitroHooks.callHook("cloudflare:queue", {
|
|
54
|
+
batch,
|
|
55
|
+
event: batch,
|
|
56
|
+
env,
|
|
57
|
+
context
|
|
58
|
+
}) || Promise.resolve());
|
|
59
|
+
},
|
|
60
|
+
tail(traces, env, context) {
|
|
61
|
+
globalThis.__env__ = env;
|
|
62
|
+
context.waitUntil(nitroHooks.callHook("cloudflare:tail", {
|
|
63
|
+
traces,
|
|
64
|
+
env,
|
|
65
|
+
context
|
|
66
|
+
}) || Promise.resolve());
|
|
67
|
+
},
|
|
68
|
+
trace(traces, env, context) {
|
|
69
|
+
globalThis.__env__ = env;
|
|
70
|
+
context.waitUntil(nitroHooks.callHook("cloudflare:trace", {
|
|
71
|
+
traces,
|
|
72
|
+
env,
|
|
73
|
+
context
|
|
74
|
+
}) || Promise.resolve());
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function augmentReq(cfReq, ctx) {
|
|
79
|
+
const req = cfReq;
|
|
80
|
+
req.ip = cfReq.headers.get("cf-connecting-ip") || undefined;
|
|
81
|
+
req.runtime ??= { name: "cloudflare" };
|
|
82
|
+
req.runtime.cloudflare = {
|
|
83
|
+
...req.runtime.cloudflare,
|
|
84
|
+
...ctx
|
|
85
|
+
};
|
|
86
|
+
req.waitUntil = ctx.context?.waitUntil.bind(ctx.context);
|
|
87
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import { DurableObject } from "cloudflare:workers";
|
|
3
|
+
import wsAdapter from "crossws/adapters/cloudflare";
|
|
4
|
+
import { createHandler, augmentReq } from "./_module-handler.mjs";
|
|
5
|
+
import { useNitroApp, useNitroHooks } from "nitro/app";
|
|
6
|
+
import { isPublicAssetURL } from "#nitro/virtual/public-assets";
|
|
7
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
8
|
+
const DURABLE_BINDING = "$DurableObject";
|
|
9
|
+
const DURABLE_INSTANCE = "server";
|
|
10
|
+
const nitroApp = useNitroApp();
|
|
11
|
+
const nitroHooks = useNitroHooks();
|
|
12
|
+
const getDurableStub = (env) => {
|
|
13
|
+
const binding = env[DURABLE_BINDING];
|
|
14
|
+
if (!binding) {
|
|
15
|
+
throw new Error(`Durable Object binding "${DURABLE_BINDING}" not available.`);
|
|
16
|
+
}
|
|
17
|
+
const id = binding.idFromName(DURABLE_INSTANCE);
|
|
18
|
+
return binding.get(id);
|
|
19
|
+
};
|
|
20
|
+
const ws = import.meta._websocket ? wsAdapter({
|
|
21
|
+
resolve: resolveWebsocketHooks,
|
|
22
|
+
instanceName: DURABLE_INSTANCE,
|
|
23
|
+
bindingName: DURABLE_BINDING
|
|
24
|
+
}) : undefined;
|
|
25
|
+
export default createHandler({ fetch(request, env, context, url, ctxExt) {
|
|
26
|
+
// Static assets fallback (optional binding)
|
|
27
|
+
if (env.ASSETS && isPublicAssetURL(url.pathname)) {
|
|
28
|
+
return env.ASSETS.fetch(request);
|
|
29
|
+
}
|
|
30
|
+
// Expose stub fetch to the context
|
|
31
|
+
ctxExt.durableFetch = (req = request) => getDurableStub(env).fetch(req);
|
|
32
|
+
// Websocket upgrade
|
|
33
|
+
// https://crossws.unjs.io/adapters/cloudflare#durable-objects
|
|
34
|
+
if (import.meta._websocket && request.headers.get("upgrade") === "websocket") {
|
|
35
|
+
return ws.handleUpgrade(request, env, context);
|
|
36
|
+
}
|
|
37
|
+
} });
|
|
38
|
+
export class $DurableObject extends DurableObject {
|
|
39
|
+
constructor(state, env) {
|
|
40
|
+
super(state, env);
|
|
41
|
+
state.waitUntil(nitroHooks.callHook("cloudflare:durable:init", this, {
|
|
42
|
+
state,
|
|
43
|
+
env
|
|
44
|
+
}) || Promise.resolve());
|
|
45
|
+
if (import.meta._websocket) {
|
|
46
|
+
ws.handleDurableInit(this, state, env);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
fetch(request) {
|
|
50
|
+
augmentReq(request, {
|
|
51
|
+
env: this.env,
|
|
52
|
+
context: this.ctx
|
|
53
|
+
});
|
|
54
|
+
if (import.meta._websocket && request.headers.get("upgrade") === "websocket") {
|
|
55
|
+
return ws.handleDurableUpgrade(this, request);
|
|
56
|
+
}
|
|
57
|
+
return nitroApp.fetch(request);
|
|
58
|
+
}
|
|
59
|
+
alarm() {
|
|
60
|
+
this.ctx.waitUntil(nitroHooks.callHook("cloudflare:durable:alarm", this) || Promise.resolve());
|
|
61
|
+
}
|
|
62
|
+
async webSocketMessage(client, message) {
|
|
63
|
+
if (import.meta._websocket) {
|
|
64
|
+
return ws.handleDurableMessage(this, client, message);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async webSocketClose(client, code, reason, wasClean) {
|
|
68
|
+
if (import.meta._websocket) {
|
|
69
|
+
return ws.handleDurableClose(this, client, code, reason, wasClean);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import wsAdapter from "crossws/adapters/cloudflare";
|
|
3
|
+
import { isPublicAssetURL } from "#nitro/virtual/public-assets";
|
|
4
|
+
import { createHandler } from "./_module-handler.mjs";
|
|
5
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
6
|
+
const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
|
|
7
|
+
export default createHandler({ fetch(cfRequest, env, context, url) {
|
|
8
|
+
// Static assets fallback (optional binding)
|
|
9
|
+
if (env.ASSETS && isPublicAssetURL(url.pathname)) {
|
|
10
|
+
return env.ASSETS.fetch(cfRequest);
|
|
11
|
+
}
|
|
12
|
+
// Websocket upgrade
|
|
13
|
+
// https://crossws.unjs.io/adapters/cloudflare
|
|
14
|
+
if (import.meta._websocket && cfRequest.headers.get("upgrade") === "websocket") {
|
|
15
|
+
return ws.handleUpgrade(cfRequest, env, context);
|
|
16
|
+
}
|
|
17
|
+
} });
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import wsAdapter from "crossws/adapters/cloudflare";
|
|
3
|
+
import { useNitroApp } from "nitro/app";
|
|
4
|
+
import { isPublicAssetURL } from "#nitro/virtual/public-assets";
|
|
5
|
+
import { runCronTasks } from "#nitro/runtime/task";
|
|
6
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
7
|
+
import { augmentReq } from "./_module-handler.mjs";
|
|
8
|
+
const nitroApp = useNitroApp();
|
|
9
|
+
const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
|
|
10
|
+
export default {
|
|
11
|
+
async fetch(cfReq, env, context) {
|
|
12
|
+
augmentReq(cfReq, {
|
|
13
|
+
env,
|
|
14
|
+
context
|
|
15
|
+
});
|
|
16
|
+
// Websocket upgrade
|
|
17
|
+
// https://crossws.unjs.io/adapters/cloudflare
|
|
18
|
+
if (import.meta._websocket && cfReq.headers.get("upgrade") === "websocket") {
|
|
19
|
+
return ws.handleUpgrade(cfReq, env, context);
|
|
20
|
+
}
|
|
21
|
+
const url = new URL(cfReq.url);
|
|
22
|
+
if (env.ASSETS && isPublicAssetURL(url.pathname)) {
|
|
23
|
+
return env.ASSETS.fetch(cfReq);
|
|
24
|
+
}
|
|
25
|
+
return nitroApp.fetch(cfReq);
|
|
26
|
+
},
|
|
27
|
+
scheduled(event, env, context) {
|
|
28
|
+
if (import.meta._tasks) {
|
|
29
|
+
globalThis.__env__ = env;
|
|
30
|
+
context.waitUntil(runCronTasks(event.cron, {
|
|
31
|
+
context: { cloudflare: {
|
|
32
|
+
env,
|
|
33
|
+
context
|
|
34
|
+
} },
|
|
35
|
+
payload: {}
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "nitro/runtime-config";
|
|
2
|
+
const proxy = await _getPlatformProxy().catch((error) => {
|
|
3
|
+
console.error("Failed to initialize wrangler bindings proxy", error);
|
|
4
|
+
return _createStubProxy();
|
|
5
|
+
});
|
|
6
|
+
globalThis.__env__ = proxy.env;
|
|
7
|
+
globalThis.__wait_until__ = proxy.ctx.waitUntil.bind(proxy.ctx);
|
|
8
|
+
const cloudflareDevPlugin = function(nitroApp) {
|
|
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
|
+
const request = event.req;
|
|
15
|
+
request.cf = proxy.cf;
|
|
16
|
+
event.req.context.cloudflare = {
|
|
17
|
+
...event.req.context.cloudflare,
|
|
18
|
+
request,
|
|
19
|
+
env: proxy.env,
|
|
20
|
+
context: proxy.ctx
|
|
21
|
+
};
|
|
22
|
+
// Replicate Nitro production behavior
|
|
23
|
+
// https://github.com/unjs/nitro/blob/main/src/runtime/entries/cloudflare-pages.ts#L55
|
|
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
|
+
// };
|
|
30
|
+
});
|
|
31
|
+
// https://github.com/pi0/nitro-cloudflare-dev/issues/5
|
|
32
|
+
// https://github.com/unjs/hookable/issues/98
|
|
33
|
+
// @ts-expect-error
|
|
34
|
+
nitroApp.hooks._hooks.request.unshift(nitroApp.hooks._hooks.request.pop());
|
|
35
|
+
// Dispose proxy when Nitro is closed
|
|
36
|
+
nitroApp.hooks.hook("close", () => {
|
|
37
|
+
return proxy?.dispose();
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export default cloudflareDevPlugin;
|
|
41
|
+
async function _getPlatformProxy() {
|
|
42
|
+
const pkg = "wrangler";
|
|
43
|
+
const { getPlatformProxy } = await import(
|
|
44
|
+
/* @vite-ignore */
|
|
45
|
+
pkg
|
|
46
|
+
).catch(() => {
|
|
47
|
+
throw new Error("Package `wrangler` not found, please install it with: `npx nypm@latest add -D wrangler`");
|
|
48
|
+
});
|
|
49
|
+
const runtimeConfig = useRuntimeConfig();
|
|
50
|
+
const proxyOptions = {
|
|
51
|
+
configPath: runtimeConfig.wrangler.configPath,
|
|
52
|
+
persist: { path: runtimeConfig.wrangler.persistDir }
|
|
53
|
+
};
|
|
54
|
+
// TODO: investigate why
|
|
55
|
+
// https://github.com/pi0/nitro-cloudflare-dev/issues/51
|
|
56
|
+
if (runtimeConfig.wrangler.environment) {
|
|
57
|
+
proxyOptions.environment = runtimeConfig.wrangler.environment;
|
|
58
|
+
}
|
|
59
|
+
const proxy = await getPlatformProxy(proxyOptions);
|
|
60
|
+
return proxy;
|
|
61
|
+
}
|
|
62
|
+
function _createStubProxy() {
|
|
63
|
+
return {
|
|
64
|
+
env: {},
|
|
65
|
+
cf: {},
|
|
66
|
+
ctx: {
|
|
67
|
+
waitUntil() {},
|
|
68
|
+
passThroughOnException() {},
|
|
69
|
+
props: {}
|
|
70
|
+
},
|
|
71
|
+
caches: {
|
|
72
|
+
open() {
|
|
73
|
+
const result = Promise.resolve(new _CacheStub());
|
|
74
|
+
return result;
|
|
75
|
+
},
|
|
76
|
+
get default() {
|
|
77
|
+
return new _CacheStub();
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
dispose: () => Promise.resolve()
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
class _CacheStub {
|
|
84
|
+
delete() {
|
|
85
|
+
const result = Promise.resolve(false);
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
match() {
|
|
89
|
+
const result = Promise.resolve(undefined);
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
put() {
|
|
93
|
+
const result = Promise.resolve();
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Shim for "cloudflare:workers" import in dev environment
|
|
2
|
+
|
|
3
|
+
// unenv shim respects __env__
|
|
4
|
+
export { env } from "unenv/node/internal/process/env";
|
|
5
|
+
|
|
6
|
+
export async function waitUntil(promise) {
|
|
7
|
+
await globalThis.__wait_until__?.(promise);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function withEnv(newEnv, fn) {
|
|
11
|
+
throw new Error("cf.withEnv is not implemented in dev env currently.");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class NotImplemented {
|
|
15
|
+
constructor() {
|
|
16
|
+
throw new Error("Not implemented in dev env currently.");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class DurableObject extends NotImplemented {}
|
|
21
|
+
export class RpcPromise extends NotImplemented {}
|
|
22
|
+
export class RpcProperty extends NotImplemented {}
|
|
23
|
+
export class RpcStub extends NotImplemented {}
|
|
24
|
+
export class RpcTarget extends NotImplemented {}
|
|
25
|
+
export class ServiceStub extends NotImplemented {}
|
|
26
|
+
export class WorkerEntrypoint extends NotImplemented {}
|
|
27
|
+
export class WorkflowEntrypoint extends NotImplemented {}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import wsAdapter from "crossws/adapters/deno";
|
|
3
|
+
import { useNitroApp } from "nitro/app";
|
|
4
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
5
|
+
const nitroApp = useNitroApp();
|
|
6
|
+
const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
|
|
7
|
+
// TODO: Migrate to srvx to provide request IP
|
|
8
|
+
Deno.serve((denoReq, info) => {
|
|
9
|
+
// srvx compatibility
|
|
10
|
+
const req = denoReq;
|
|
11
|
+
req.runtime ??= { name: "deno" };
|
|
12
|
+
req.runtime.deno ??= { info };
|
|
13
|
+
// TODO: Support remoteAddr
|
|
14
|
+
// https://crossws.unjs.io/adapters/deno
|
|
15
|
+
if (import.meta._websocket && req.headers.get("upgrade") === "websocket") {
|
|
16
|
+
return ws.handleUpgrade(req, info);
|
|
17
|
+
}
|
|
18
|
+
return nitroApp.fetch(req);
|
|
19
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import { serve } from "srvx/deno";
|
|
3
|
+
import wsAdapter from "crossws/adapters/deno";
|
|
4
|
+
import { useNitroApp } from "nitro/app";
|
|
5
|
+
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
6
|
+
import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
|
|
7
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
8
|
+
const _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
|
|
9
|
+
const port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
|
|
10
|
+
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
11
|
+
const cert = process.env.NITRO_SSL_CERT;
|
|
12
|
+
const key = process.env.NITRO_SSL_KEY;
|
|
13
|
+
// const socketPath = process.env.NITRO_UNIX_SOCKET; // TODO
|
|
14
|
+
const nitroApp = useNitroApp();
|
|
15
|
+
let _fetch = nitroApp.fetch;
|
|
16
|
+
if (import.meta._websocket) {
|
|
17
|
+
const { handleUpgrade } = wsAdapter({ resolve: resolveWebsocketHooks });
|
|
18
|
+
_fetch = (req) => {
|
|
19
|
+
if (req.headers.get("upgrade") === "websocket") {
|
|
20
|
+
return handleUpgrade(req, req.runtime.deno.info);
|
|
21
|
+
}
|
|
22
|
+
return nitroApp.fetch(req);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const server = serve({
|
|
26
|
+
port,
|
|
27
|
+
hostname: host,
|
|
28
|
+
tls: cert && key ? {
|
|
29
|
+
cert,
|
|
30
|
+
key
|
|
31
|
+
} : undefined,
|
|
32
|
+
fetch: _fetch
|
|
33
|
+
});
|
|
34
|
+
trapUnhandledErrors();
|
|
35
|
+
// Scheduled tasks
|
|
36
|
+
if (import.meta._tasks) {
|
|
37
|
+
startScheduleRunner({ waitUntil: server.waitUntil });
|
|
38
|
+
}
|
|
39
|
+
export default {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import { useNitroApp } from "nitro/app";
|
|
3
|
+
import { isPublicAssetURL } from "#nitro/virtual/public-assets";
|
|
4
|
+
const nitroApp = useNitroApp();
|
|
5
|
+
// https://docs.netlify.com/edge-functions/api/
|
|
6
|
+
export default async function netlifyEdge(netlifyReq, context) {
|
|
7
|
+
// srvx compatibility
|
|
8
|
+
const req = netlifyReq;
|
|
9
|
+
req.ip = context.ip;
|
|
10
|
+
req.runtime ??= { name: "netlify-edge" };
|
|
11
|
+
req.runtime.netlify ??= { context };
|
|
12
|
+
const url = new URL(req.url);
|
|
13
|
+
if (isPublicAssetURL(url.pathname)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!req.headers.has("x-forwarded-proto") && url.protocol === "https:") {
|
|
17
|
+
req.headers.set("x-forwarded-proto", "https");
|
|
18
|
+
}
|
|
19
|
+
return nitroApp.fetch(req);
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import { useNitroApp } from "nitro/app";
|
|
3
|
+
const nitroApp = useNitroApp();
|
|
4
|
+
const ONE_YEAR_IN_SECONDS = 365 * 24 * 60 * 60;
|
|
5
|
+
const handler = async (req) => {
|
|
6
|
+
req.runtime ??= { name: "netlify" };
|
|
7
|
+
req.ip ??= req.headers.get("x-nf-client-connection-ip") || undefined;
|
|
8
|
+
const response = await nitroApp.fetch(req);
|
|
9
|
+
const isr = (req.context?.routeRules || {})?.isr?.options;
|
|
10
|
+
if (isr) {
|
|
11
|
+
const maxAge = typeof isr === "number" ? isr : ONE_YEAR_IN_SECONDS;
|
|
12
|
+
const revalidateDirective = typeof isr === "number" ? `stale-while-revalidate=${ONE_YEAR_IN_SECONDS}` : "must-revalidate";
|
|
13
|
+
if (!response.headers.has("Cache-Control")) {
|
|
14
|
+
response.headers.set("Cache-Control", "public, max-age=0, must-revalidate");
|
|
15
|
+
}
|
|
16
|
+
response.headers.set("Netlify-CDN-Cache-Control", `public, max-age=${maxAge}, ${revalidateDirective}, durable`);
|
|
17
|
+
}
|
|
18
|
+
return response;
|
|
19
|
+
};
|
|
20
|
+
export default handler;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import cluster from "node:cluster";
|
|
3
|
+
import { NodeRequest, serve } from "srvx/node";
|
|
4
|
+
import wsAdapter from "crossws/adapters/node";
|
|
5
|
+
import { useNitroApp } from "nitro/app";
|
|
6
|
+
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
7
|
+
import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
|
|
8
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
9
|
+
const _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
|
|
10
|
+
const port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
|
|
11
|
+
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
12
|
+
const cert = process.env.NITRO_SSL_CERT;
|
|
13
|
+
const key = process.env.NITRO_SSL_KEY;
|
|
14
|
+
// const socketPath = process.env.NITRO_UNIX_SOCKET; // TODO
|
|
15
|
+
const clusterId = cluster.isWorker && process.env.WORKER_ID;
|
|
16
|
+
if (clusterId) {
|
|
17
|
+
console.log(`Worker #${clusterId} started`);
|
|
18
|
+
}
|
|
19
|
+
const nitroApp = useNitroApp();
|
|
20
|
+
const server = serve({
|
|
21
|
+
port,
|
|
22
|
+
hostname: host,
|
|
23
|
+
tls: cert && key ? {
|
|
24
|
+
cert,
|
|
25
|
+
key
|
|
26
|
+
} : undefined,
|
|
27
|
+
node: { exclusive: false },
|
|
28
|
+
silent: clusterId ? clusterId !== "1" : undefined,
|
|
29
|
+
fetch: nitroApp.fetch
|
|
30
|
+
});
|
|
31
|
+
if (import.meta._websocket) {
|
|
32
|
+
const { handleUpgrade } = wsAdapter({ resolve: resolveWebsocketHooks });
|
|
33
|
+
server.node.server.on("upgrade", (req, socket, head) => {
|
|
34
|
+
handleUpgrade(
|
|
35
|
+
req,
|
|
36
|
+
socket,
|
|
37
|
+
head,
|
|
38
|
+
// @ts-expect-error (upgrade is not typed)
|
|
39
|
+
new NodeRequest({
|
|
40
|
+
req,
|
|
41
|
+
upgrade: {
|
|
42
|
+
socket,
|
|
43
|
+
head
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
trapUnhandledErrors();
|
|
50
|
+
// Scheduled tasks
|
|
51
|
+
if (import.meta._tasks) {
|
|
52
|
+
startScheduleRunner({ waitUntil: server.waitUntil });
|
|
53
|
+
}
|
|
54
|
+
export default {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import { toNodeHandler } from "srvx/node";
|
|
3
|
+
import wsAdapter from "crossws/adapters/node";
|
|
4
|
+
import { useNitroApp } from "nitro/app";
|
|
5
|
+
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
6
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
7
|
+
const nitroApp = useNitroApp();
|
|
8
|
+
export const middleware = toNodeHandler(nitroApp.fetch);
|
|
9
|
+
const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
|
|
10
|
+
export const handleUpgrade = ws?.handleUpgrade;
|
|
11
|
+
// Scheduled tasks
|
|
12
|
+
if (import.meta._tasks) {
|
|
13
|
+
startScheduleRunner();
|
|
14
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import { NodeRequest, serve } from "srvx/node";
|
|
3
|
+
import wsAdapter from "crossws/adapters/node";
|
|
4
|
+
import { useNitroApp } from "nitro/app";
|
|
5
|
+
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
6
|
+
import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
|
|
7
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
8
|
+
const _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
|
|
9
|
+
const port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
|
|
10
|
+
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
11
|
+
const cert = process.env.NITRO_SSL_CERT;
|
|
12
|
+
const key = process.env.NITRO_SSL_KEY;
|
|
13
|
+
// const socketPath = process.env.NITRO_UNIX_SOCKET; // TODO
|
|
14
|
+
const nitroApp = useNitroApp();
|
|
15
|
+
const server = serve({
|
|
16
|
+
port,
|
|
17
|
+
hostname: host,
|
|
18
|
+
tls: cert && key ? {
|
|
19
|
+
cert,
|
|
20
|
+
key
|
|
21
|
+
} : undefined,
|
|
22
|
+
fetch: nitroApp.fetch
|
|
23
|
+
});
|
|
24
|
+
if (import.meta._websocket) {
|
|
25
|
+
const { handleUpgrade } = wsAdapter({ resolve: resolveWebsocketHooks });
|
|
26
|
+
server.node.server.on("upgrade", (req, socket, head) => {
|
|
27
|
+
handleUpgrade(
|
|
28
|
+
req,
|
|
29
|
+
socket,
|
|
30
|
+
head,
|
|
31
|
+
// @ts-expect-error (upgrade is not typed)
|
|
32
|
+
new NodeRequest({
|
|
33
|
+
req,
|
|
34
|
+
upgrade: {
|
|
35
|
+
socket,
|
|
36
|
+
head
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
trapUnhandledErrors();
|
|
43
|
+
// Scheduled tasks
|
|
44
|
+
if (import.meta._tasks) {
|
|
45
|
+
startScheduleRunner({ waitUntil: server.waitUntil });
|
|
46
|
+
}
|
|
47
|
+
export default {};
|