nitro 2.2.27 → 3.0.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 +2 -2
- package/README.md +11 -259
- package/dist/_chunks/app.mjs +19797 -0
- package/dist/_chunks/build.mjs +84 -0
- package/dist/_chunks/build2.mjs +318 -0
- package/dist/_chunks/build3.mjs +6452 -0
- package/dist/_chunks/detect-acorn.mjs +503 -0
- package/dist/_chunks/index.mjs +22242 -0
- package/dist/_chunks/index2.mjs +297 -0
- package/dist/_chunks/index3.mjs +1058 -0
- package/dist/_chunks/index4.mjs +1206 -0
- package/dist/_chunks/info.mjs +11157 -0
- package/dist/_chunks/json5.mjs +68 -0
- package/dist/_chunks/jsonc.mjs +51 -0
- package/dist/_chunks/pathe.M-eThtNZ.mjs +204 -0
- package/dist/_chunks/plugin.mjs +960 -0
- package/dist/_chunks/server.mjs +254 -0
- package/dist/_chunks/snapshot.mjs +284 -0
- package/dist/_chunks/toml.mjs +259 -0
- package/dist/_chunks/yaml.mjs +86 -0
- package/dist/cli/build.mjs +54 -0
- package/dist/cli/common.mjs +13 -0
- package/dist/cli/dev.mjs +95 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +477 -0
- package/dist/cli/index2.mjs +17 -0
- package/dist/cli/list.mjs +34 -0
- package/dist/cli/prepare.mjs +24 -0
- package/dist/cli/run.mjs +60 -0
- package/dist/index.d.mts +52 -0
- package/dist/index.mjs +55 -0
- package/dist/node_modules/@poppinss/colors/build/index.js +169 -0
- package/dist/node_modules/@poppinss/colors/package.json +116 -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 +717 -0
- package/dist/node_modules/@poppinss/dumper/package.json +122 -0
- package/dist/node_modules/@poppinss/exception/build/index.js +63 -0
- package/dist/node_modules/@poppinss/exception/package.json +106 -0
- package/dist/node_modules/@sindresorhus/is/distribution/index.js +1313 -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 +90 -0
- package/dist/node_modules/cookie/dist/index.js +239 -0
- package/dist/node_modules/cookie/package.json +42 -0
- package/dist/node_modules/croner/dist/croner.js +1 -0
- package/dist/node_modules/croner/package.json +63 -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/hookable/dist/index.mjs +290 -0
- package/dist/node_modules/hookable/package.json +49 -0
- package/dist/node_modules/kleur/index.js +110 -0
- package/dist/node_modules/kleur/index.mjs +110 -0
- package/dist/node_modules/kleur/package.json +51 -0
- package/dist/node_modules/klona/dist/index.mjs +81 -0
- package/dist/node_modules/klona/full/index.mjs +53 -0
- package/dist/node_modules/klona/package.json +74 -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/std-env/dist/index.mjs +1 -0
- package/dist/node_modules/std-env/package.json +46 -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 +638 -0
- package/dist/node_modules/ufo/package.json +47 -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/chunk-4L7RY2JA.js +42 -0
- package/dist/node_modules/youch/build/chunk-4XB2BYKC.js +85 -0
- package/dist/node_modules/youch/build/chunk-4YEN7HVQ.js +61 -0
- package/dist/node_modules/youch/build/chunk-EUJBVOYB.js +83 -0
- package/dist/node_modules/youch/build/chunk-HFSXRSKS.js +85 -0
- package/dist/node_modules/youch/build/chunk-JAN2TFI2.js +222 -0
- package/dist/node_modules/youch/build/chunk-OSUFJZHZ.js +6 -0
- package/dist/node_modules/youch/build/chunk-PINJDICN.js +72 -0
- package/dist/node_modules/youch/build/chunk-PUHGL6HA.js +41 -0
- package/dist/node_modules/youch/build/chunk-VE4LENUR.js +45 -0
- package/dist/node_modules/youch/build/index.js +352 -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 +144 -0
- package/dist/node_modules/youch/build/public/error_stack/script.js +74 -0
- package/dist/node_modules/youch/build/public/error_stack/style.css +220 -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 +16 -0
- package/dist/node_modules/youch/build/public/header/style.css +56 -0
- package/dist/node_modules/youch/build/public/layout/script.js +20 -0
- package/dist/node_modules/youch/build/public/layout/style.css +431 -0
- package/dist/node_modules/youch/package.json +133 -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.d.mts +1 -0
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +62 -0
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +3 -0
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +18 -0
- package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +21 -0
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +13 -0
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +18 -0
- package/dist/presets/aws-lambda/runtime/_utils.mjs +102 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +3 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +33 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +3 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +13 -0
- package/dist/presets/azure/runtime/_utils.d.mts +2 -0
- package/dist/presets/azure/runtime/_utils.mjs +50 -0
- package/dist/presets/azure/runtime/azure-swa.d.mts +5 -0
- package/dist/presets/azure/runtime/azure-swa.mjs +28 -0
- package/dist/presets/bun/runtime/bun.d.mts +1 -0
- package/dist/presets/bun/runtime/bun.mjs +27 -0
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +13 -0
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +93 -0
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +19 -0
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +74 -0
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +9 -0
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +20 -0
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +20 -0
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +47 -0
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +3 -0
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +89 -0
- package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -0
- package/dist/presets/deno/runtime/deno-deploy.mjs +17 -0
- package/dist/presets/deno/runtime/deno-server.d.mts +6 -0
- package/dist/presets/deno/runtime/deno-server.mjs +59 -0
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +3 -0
- package/dist/presets/netlify/runtime/netlify-edge.mjs +17 -0
- package/dist/presets/netlify/runtime/netlify.d.mts +3 -0
- package/dist/presets/netlify/runtime/netlify.mjs +24 -0
- package/dist/presets/node/runtime/node-cluster.d.mts +1 -0
- package/dist/presets/node/runtime/node-cluster.mjs +58 -0
- package/dist/presets/node/runtime/node-middleware.d.mts +4 -0
- package/dist/presets/node/runtime/node-middleware.mjs +14 -0
- package/dist/presets/node/runtime/node-server.d.mts +3 -0
- package/dist/presets/node/runtime/node-server.mjs +44 -0
- package/dist/presets/standard/runtime/server.d.mts +5 -0
- package/dist/presets/standard/runtime/server.mjs +6 -0
- package/dist/presets/stormkit/runtime/stormkit.d.mts +21 -0
- package/dist/presets/stormkit/runtime/stormkit.mjs +28 -0
- package/dist/presets/vercel/runtime/vercel.d.mts +8 -0
- package/dist/presets/vercel/runtime/vercel.mjs +17 -0
- package/dist/presets/winterjs/runtime/winterjs.d.mts +1 -0
- package/dist/presets/winterjs/runtime/winterjs.mjs +87 -0
- package/dist/presets/zeabur/runtime/zeabur.d.mts +3 -0
- package/dist/presets/zeabur/runtime/zeabur.mjs +4 -0
- package/dist/presets.mjs +2460 -0
- package/dist/runtime/index.d.mts +11 -0
- package/dist/runtime/index.mjs +17 -0
- package/dist/runtime/internal/app.d.mts +2 -0
- package/dist/runtime/internal/app.mjs +153 -0
- package/dist/runtime/internal/cache.d.mts +7 -0
- package/dist/runtime/internal/cache.mjs +236 -0
- package/dist/runtime/internal/context.d.mts +12 -0
- package/dist/runtime/internal/context.mjs +17 -0
- package/dist/runtime/internal/database.d.mts +2 -0
- package/dist/runtime/internal/database.mjs +14 -0
- package/dist/runtime/internal/debug.d.mts +2 -0
- package/dist/runtime/internal/debug.mjs +5 -0
- package/dist/runtime/internal/empty.d.mts +0 -0
- package/dist/runtime/internal/empty.mjs +0 -0
- package/dist/runtime/internal/error/dev.d.mts +9 -0
- package/dist/runtime/internal/error/dev.mjs +122 -0
- package/dist/runtime/internal/error/prod.d.mts +8 -0
- package/dist/runtime/internal/error/prod.mjs +62 -0
- package/dist/runtime/internal/error/utils.d.mts +8 -0
- package/dist/runtime/internal/error/utils.mjs +3 -0
- package/dist/runtime/internal/index.d.mts +3 -0
- package/dist/runtime/internal/index.mjs +3 -0
- package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +16 -0
- package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +213 -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/renderer.d.mts +3 -0
- package/dist/runtime/internal/renderer.mjs +36 -0
- package/dist/runtime/internal/route-rules.d.mts +8 -0
- package/dist/runtime/internal/route-rules.mjs +62 -0
- package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -0
- package/dist/runtime/internal/routes/dev-tasks.mjs +23 -0
- package/dist/runtime/internal/routes/openapi.d.mts +3 -0
- package/dist/runtime/internal/routes/openapi.mjs +100 -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 +21 -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 +194 -0
- package/dist/runtime/internal/routes/swagger.d.mts +3 -0
- package/dist/runtime/internal/routes/swagger.mjs +44 -0
- package/dist/runtime/internal/runtime-config.d.mts +9 -0
- package/dist/runtime/internal/runtime-config.mjs +49 -0
- package/dist/runtime/internal/shutdown.d.mts +9 -0
- package/dist/runtime/internal/shutdown.mjs +34 -0
- package/dist/runtime/internal/static.d.mts +3 -0
- package/dist/runtime/internal/static.mjs +77 -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 +17 -0
- package/dist/runtime/internal/task.mjs +73 -0
- package/dist/runtime/internal/utils.d.mts +1 -0
- package/dist/runtime/internal/utils.mjs +15 -0
- package/dist/runtime/internal/vite/dev-entry.d.mts +1 -0
- package/dist/runtime/internal/vite/dev-entry.mjs +6 -0
- package/dist/runtime/internal/vite/dev-worker.d.mts +1 -0
- package/dist/runtime/internal/vite/dev-worker.mjs +362 -0
- package/dist/runtime/internal/vite/prod-setup.d.mts +4 -0
- package/dist/runtime/internal/vite/prod-setup.mjs +55 -0
- package/dist/runtime/internal/vite/ssr-renderer.d.mts +4 -0
- package/dist/runtime/internal/vite/ssr-renderer.mjs +4 -0
- package/dist/types/index.d.mts +2810 -0
- package/dist/types/index.mjs +1 -0
- package/dist/vite.d.mts +59 -0
- package/dist/vite.mjs +68 -0
- package/lib/config.d.mts +9 -0
- package/lib/config.mjs +5 -0
- package/lib/deps/h3.d.mts +1 -0
- package/lib/deps/h3.mjs +1 -0
- package/lib/deps/ofetch.mjs +1 -0
- package/lib/deps/ofetch.mts +1 -0
- package/lib/meta.d.mts +5 -0
- package/lib/meta.mjs +21 -0
- package/lib/runtime-meta.d.mts +5 -0
- package/lib/runtime-meta.mjs +38 -0
- package/package.json +170 -38
- package/.editorconfig +0 -12
- package/.eslintrc.js +0 -34
- package/.travis.yml +0 -7
- package/Dockerfile +0 -12
- package/Makefile +0 -37
- package/bin/nitro +0 -55
- package/lib/auto-require.js +0 -44
- package/lib/class-file.js +0 -105
- package/lib/class-files.js +0 -212
- package/lib/color.js +0 -89
- package/lib/cwd.js +0 -27
- package/lib/dir-expand.js +0 -80
- package/lib/dir.js +0 -130
- package/lib/file.js +0 -80
- package/lib/join-paths.js +0 -60
- package/lib/livereload/livereload.js +0 -55
- package/lib/livereload.js +0 -86
- package/lib/nitro.js +0 -161
- package/lib/package.js +0 -211
- package/lib/presets/autoprefixer.js +0 -11
- package/lib/presets/babel.js +0 -33
- package/lib/presets/browserify.js +0 -106
- package/lib/presets/coffee-script.js +0 -29
- package/lib/presets/cssnano.js +0 -11
- package/lib/presets/eslint.js +0 -67
- package/lib/presets/jshint.js +0 -51
- package/lib/presets/less.js +0 -45
- package/lib/presets/log.js +0 -11
- package/lib/presets/ng-annotate.js +0 -34
- package/lib/presets/noop.js +0 -7
- package/lib/presets/postcss/auto-postcss.js +0 -46
- package/lib/presets/postcss/autoprefixer-options.js +0 -9
- package/lib/presets/postcss.js +0 -40
- package/lib/presets/rollup.js +0 -56
- package/lib/presets/sass.js +0 -64
- package/lib/presets/sitemap.js +0 -101
- package/lib/presets/sitemap.xml +0 -12
- package/lib/presets/svg-symbols.js +0 -22
- package/lib/presets/svgo.js +0 -21
- package/lib/presets/uglify.js +0 -72
- package/lib/presets/webpack.js +0 -66
- package/lib/processors.js +0 -84
- package/lib/promisify.js +0 -16
- package/lib/server.js +0 -224
- package/lib/tasks.js +0 -114
- package/lib/watch.js +0 -81
- package/test.js +0 -59
- package/tests/cwd-tests.js +0 -25
- package/tests/dir-tests.js +0 -80
- package/tests/dummy/dummy.coffee +0 -7
- package/tests/dummy/dummy.js +0 -8
- package/tests/dummy/dummy.less +0 -6
- package/tests/dummy/dummy.sass +0 -5
- package/tests/file-tests.js +0 -17
- package/tests/join-paths-tests.js +0 -86
- package/tests/tasks-tests.js +0 -65
- package/wercker.yml +0 -25
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import { useNitroApp } from "nitro/runtime";
|
|
3
|
+
import { awsRequest, awsResponseHeaders } from "./_utils.mjs";
|
|
4
|
+
const nitroApp = useNitroApp();
|
|
5
|
+
export const handler = awslambda.streamifyResponse(
|
|
6
|
+
async (event, responseStream, context) => {
|
|
7
|
+
const request = awsRequest(event, context);
|
|
8
|
+
const response = await nitroApp.fetch(request);
|
|
9
|
+
response.headers.set("transfer-encoding", "chunked");
|
|
10
|
+
const httpResponseMetadata = {
|
|
11
|
+
statusCode: response.status,
|
|
12
|
+
...awsResponseHeaders(response)
|
|
13
|
+
};
|
|
14
|
+
if (response.body) {
|
|
15
|
+
const writer = awslambda.HttpResponseStream.from(
|
|
16
|
+
// @ts-expect-error TODO: IMPORTANT! It should be a Writable according to the aws-lambda types
|
|
17
|
+
responseStream,
|
|
18
|
+
httpResponseMetadata
|
|
19
|
+
);
|
|
20
|
+
const reader = response.body.getReader();
|
|
21
|
+
await streamToNodeStream(reader, responseStream);
|
|
22
|
+
writer.end();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
async function streamToNodeStream(reader, writer) {
|
|
27
|
+
let readResult = await reader.read();
|
|
28
|
+
while (!readResult.done) {
|
|
29
|
+
writer.write(readResult.value);
|
|
30
|
+
readResult = await reader.read();
|
|
31
|
+
}
|
|
32
|
+
writer.end();
|
|
33
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyResultV2, Context } from "aws-lambda";
|
|
3
|
+
export declare function handler(event: APIGatewayProxyEvent | APIGatewayProxyEventV2, context: Context): Promise<APIGatewayProxyResult | APIGatewayProxyResultV2>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import { useNitroApp } from "nitro/runtime";
|
|
3
|
+
import { awsRequest, awsResponseHeaders, awsResponseBody } from "./_utils.mjs";
|
|
4
|
+
const nitroApp = useNitroApp();
|
|
5
|
+
export async function handler(event, context) {
|
|
6
|
+
const request = awsRequest(event, context);
|
|
7
|
+
const response = await nitroApp.fetch(request);
|
|
8
|
+
return {
|
|
9
|
+
statusCode: response.status,
|
|
10
|
+
...awsResponseHeaders(response),
|
|
11
|
+
...await awsResponseBody(response)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -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(
|
|
15
|
+
_setCookieOptions.map(([k, v]) => [k.toLowerCase(), v])
|
|
16
|
+
);
|
|
17
|
+
const cookieObject = {
|
|
18
|
+
name: key,
|
|
19
|
+
value,
|
|
20
|
+
domain: setCookieOptions.domain,
|
|
21
|
+
path: setCookieOptions.path,
|
|
22
|
+
expires: parseNumberOrDate(setCookieOptions.expires),
|
|
23
|
+
sameSite: setCookieOptions.samesite,
|
|
24
|
+
maxAge: parseNumber(setCookieOptions["max-age"]),
|
|
25
|
+
secure: setCookieStr.includes("Secure") ? true : void 0,
|
|
26
|
+
httpOnly: setCookieStr.includes("HttpOnly") ? true : void 0
|
|
27
|
+
};
|
|
28
|
+
azureCookies.push(cookieObject);
|
|
29
|
+
}
|
|
30
|
+
return azureCookies;
|
|
31
|
+
}
|
|
32
|
+
function parseNumberOrDate(expires) {
|
|
33
|
+
const expiresAsNumber = parseNumber(expires);
|
|
34
|
+
if (expiresAsNumber !== void 0) {
|
|
35
|
+
return expiresAsNumber;
|
|
36
|
+
}
|
|
37
|
+
const expiresAsDate = new Date(expires);
|
|
38
|
+
if (!Number.isNaN(expiresAsDate.getTime())) {
|
|
39
|
+
return expiresAsDate;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function parseNumber(maxAge) {
|
|
43
|
+
if (!maxAge) {
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
const maxAgeAsNumber = Number(maxAge);
|
|
47
|
+
if (!Number.isNaN(maxAgeAsNumber)) {
|
|
48
|
+
return maxAgeAsNumber;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import { parseURL } from "ufo";
|
|
3
|
+
import { useNitroApp } from "nitro/runtime";
|
|
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
|
+
const parsedURL = parseURL(req.headers["x-ms-original-url"]);
|
|
10
|
+
url = parsedURL.pathname + parsedURL.search;
|
|
11
|
+
} else {
|
|
12
|
+
url = "/api/" + (req.params.url || "");
|
|
13
|
+
}
|
|
14
|
+
const response = await nitroApp.fetch(url, {
|
|
15
|
+
method: req.method || void 0,
|
|
16
|
+
// https://github.com/Azure/azure-functions-nodejs-worker/issues/294
|
|
17
|
+
// https://github.com/Azure/azure-functions-host/issues/293
|
|
18
|
+
body: req.bufferBody ?? req.rawBody
|
|
19
|
+
});
|
|
20
|
+
context.res = {
|
|
21
|
+
status: response.status,
|
|
22
|
+
body: response.body,
|
|
23
|
+
cookies: getAzureParsedCookiesFromHeaders(response.headers),
|
|
24
|
+
headers: Object.fromEntries(
|
|
25
|
+
[...response.headers.entries()].filter(([key]) => key !== "set-cookie")
|
|
26
|
+
)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import { useNitroApp } from "nitro/runtime";
|
|
3
|
+
import { startScheduleRunner } from "nitro/runtime/internal";
|
|
4
|
+
import wsAdapter from "crossws/adapters/bun";
|
|
5
|
+
const nitroApp = useNitroApp();
|
|
6
|
+
const ws = import.meta._websocket ? (
|
|
7
|
+
// @ts-expect-error
|
|
8
|
+
wsAdapter(nitroApp.h3App.websocket)
|
|
9
|
+
) : void 0;
|
|
10
|
+
const server = Bun.serve({
|
|
11
|
+
port: process.env.NITRO_PORT || process.env.PORT || 3e3,
|
|
12
|
+
hostname: process.env.NITRO_HOST || process.env.HOST,
|
|
13
|
+
websocket: import.meta._websocket ? ws.websocket : void 0,
|
|
14
|
+
async fetch(bunReq, server2) {
|
|
15
|
+
const req = bunReq;
|
|
16
|
+
req.runtime ??= { name: "bun" };
|
|
17
|
+
req.runtime.bun ??= { server: server2 };
|
|
18
|
+
if (import.meta._websocket && req.headers.get("upgrade") === "websocket") {
|
|
19
|
+
return ws.handleUpgrade(req, server2);
|
|
20
|
+
}
|
|
21
|
+
return nitroApp.fetch(req);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
console.log(`Listening on ${server.url}...`);
|
|
25
|
+
if (import.meta._tasks) {
|
|
26
|
+
startScheduleRunner();
|
|
27
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import type * as CF from "@cloudflare/workers-types";
|
|
3
|
+
import type { ExportedHandler } from "@cloudflare/workers-types";
|
|
4
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
5
|
+
export declare function createHandler<Env>(hooks: {
|
|
6
|
+
fetch: (...params: [
|
|
7
|
+
...Parameters<NonNullable<ExportedHandler<Env>["fetch"]>>,
|
|
8
|
+
url: URL,
|
|
9
|
+
cfContextExtras: any
|
|
10
|
+
]) => MaybePromise<Response | CF.Response | undefined>;
|
|
11
|
+
}): ExportedHandler<Env>;
|
|
12
|
+
export declare function fetchHandler(cfReq: Request | CF.Request, env: unknown, context: CF.ExecutionContext | DurableObjectState, url: URL | undefined, nitroApp: any, ctxExt: any): Promise<Response>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import { useNitroApp } from "nitro/runtime";
|
|
3
|
+
import { runCronTasks } from "nitro/runtime/internal";
|
|
4
|
+
export function createHandler(hooks) {
|
|
5
|
+
const nitroApp = useNitroApp();
|
|
6
|
+
return {
|
|
7
|
+
async fetch(request, env, context) {
|
|
8
|
+
const ctxExt = {};
|
|
9
|
+
const url = new URL(request.url);
|
|
10
|
+
if (hooks.fetch) {
|
|
11
|
+
const res = await hooks.fetch(request, env, context, url, ctxExt);
|
|
12
|
+
if (res) {
|
|
13
|
+
return res;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return fetchHandler(request, env, context, url, nitroApp, ctxExt);
|
|
17
|
+
},
|
|
18
|
+
scheduled(controller, env, context) {
|
|
19
|
+
globalThis.__env__ = env;
|
|
20
|
+
context.waitUntil(
|
|
21
|
+
nitroApp.hooks.callHook("cloudflare:scheduled", {
|
|
22
|
+
controller,
|
|
23
|
+
env,
|
|
24
|
+
context
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
if (import.meta._tasks) {
|
|
28
|
+
context.waitUntil(
|
|
29
|
+
runCronTasks(controller.cron, {
|
|
30
|
+
context: {
|
|
31
|
+
cloudflare: {
|
|
32
|
+
env,
|
|
33
|
+
context
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
payload: {}
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
email(message, env, context) {
|
|
42
|
+
globalThis.__env__ = env;
|
|
43
|
+
context.waitUntil(
|
|
44
|
+
nitroApp.hooks.callHook("cloudflare:email", {
|
|
45
|
+
message,
|
|
46
|
+
event: message,
|
|
47
|
+
// backward compat
|
|
48
|
+
env,
|
|
49
|
+
context
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
queue(batch, env, context) {
|
|
54
|
+
globalThis.__env__ = env;
|
|
55
|
+
context.waitUntil(
|
|
56
|
+
nitroApp.hooks.callHook("cloudflare:queue", {
|
|
57
|
+
batch,
|
|
58
|
+
event: batch,
|
|
59
|
+
env,
|
|
60
|
+
context
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
},
|
|
64
|
+
tail(traces, env, context) {
|
|
65
|
+
globalThis.__env__ = env;
|
|
66
|
+
context.waitUntil(
|
|
67
|
+
nitroApp.hooks.callHook("cloudflare:tail", {
|
|
68
|
+
traces,
|
|
69
|
+
env,
|
|
70
|
+
context
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
trace(traces, env, context) {
|
|
75
|
+
globalThis.__env__ = env;
|
|
76
|
+
context.waitUntil(
|
|
77
|
+
nitroApp.hooks.callHook("cloudflare:trace", {
|
|
78
|
+
traces,
|
|
79
|
+
env,
|
|
80
|
+
context
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export async function fetchHandler(cfReq, env, context, url = new URL(cfReq.url), nitroApp = useNitroApp(), ctxExt) {
|
|
87
|
+
globalThis.__env__ = env;
|
|
88
|
+
const req = cfReq;
|
|
89
|
+
req.runtime ??= { name: "cloudflare" };
|
|
90
|
+
req.runtime.cloudflare ??= { context, env };
|
|
91
|
+
req.waitUntil = context.waitUntil.bind(context);
|
|
92
|
+
return nitroApp.fetch(req);
|
|
93
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import type * as CF from "@cloudflare/workers-types";
|
|
3
|
+
import { DurableObject } from "cloudflare:workers";
|
|
4
|
+
declare const DURABLE_BINDING = "$DurableObject";
|
|
5
|
+
interface Env {
|
|
6
|
+
ASSETS?: {
|
|
7
|
+
fetch: typeof CF.fetch;
|
|
8
|
+
};
|
|
9
|
+
[DURABLE_BINDING]?: CF.DurableObjectNamespace;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: CF.ExportedHandler<Env, unknown, unknown>;
|
|
12
|
+
export default _default;
|
|
13
|
+
export declare class $DurableObject extends DurableObject {
|
|
14
|
+
constructor(state: DurableObjectState, env: Record<string, any>);
|
|
15
|
+
fetch(request: Request): Promise<Response>;
|
|
16
|
+
alarm(): void | Promise<void>;
|
|
17
|
+
webSocketMessage(client: WebSocket, message: ArrayBuffer | string): Promise<void>;
|
|
18
|
+
webSocketClose(client: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import { DurableObject } from "cloudflare:workers";
|
|
3
|
+
import wsAdapter from "crossws/adapters/cloudflare";
|
|
4
|
+
import { useNitroApp } from "nitro/runtime";
|
|
5
|
+
import { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
|
|
6
|
+
import { createHandler, fetchHandler } from "./_module-handler.mjs";
|
|
7
|
+
const DURABLE_BINDING = "$DurableObject";
|
|
8
|
+
const DURABLE_INSTANCE = "server";
|
|
9
|
+
const nitroApp = useNitroApp();
|
|
10
|
+
const getDurableStub = (env) => {
|
|
11
|
+
const binding = env[DURABLE_BINDING];
|
|
12
|
+
if (!binding) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
`Durable Object binding "${DURABLE_BINDING}" not available.`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
const id = binding.idFromName(DURABLE_INSTANCE);
|
|
18
|
+
return binding.get(id);
|
|
19
|
+
};
|
|
20
|
+
const ws = import.meta._websocket ? wsAdapter({
|
|
21
|
+
// TODO!
|
|
22
|
+
// ...nitroApp.h3App.websocket,
|
|
23
|
+
instanceName: DURABLE_INSTANCE,
|
|
24
|
+
bindingName: DURABLE_BINDING
|
|
25
|
+
}) : void 0;
|
|
26
|
+
export default createHandler({
|
|
27
|
+
fetch(request, env, context, url, ctxExt) {
|
|
28
|
+
if (env.ASSETS && isPublicAssetURL(url.pathname)) {
|
|
29
|
+
return env.ASSETS.fetch(request);
|
|
30
|
+
}
|
|
31
|
+
ctxExt.durableFetch = (req = request) => getDurableStub(env).fetch(req);
|
|
32
|
+
if (import.meta._websocket && request.headers.get("upgrade") === "websocket") {
|
|
33
|
+
return ws.handleUpgrade(request, env, context);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
export class $DurableObject extends DurableObject {
|
|
38
|
+
constructor(state, env) {
|
|
39
|
+
super(state, env);
|
|
40
|
+
state.waitUntil(
|
|
41
|
+
nitroApp.hooks.callHook("cloudflare:durable:init", this, {
|
|
42
|
+
state,
|
|
43
|
+
env
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
if (import.meta._websocket) {
|
|
47
|
+
ws.handleDurableInit(this, state, env);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
fetch(request) {
|
|
51
|
+
if (import.meta._websocket && request.headers.get("upgrade") === "websocket") {
|
|
52
|
+
return ws.handleDurableUpgrade(this, request);
|
|
53
|
+
}
|
|
54
|
+
const url = new URL(request.url);
|
|
55
|
+
return fetchHandler(request, this.env, this.ctx, url, nitroApp, {
|
|
56
|
+
durable: this
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
alarm() {
|
|
60
|
+
this.ctx.waitUntil(
|
|
61
|
+
nitroApp.hooks.callHook("cloudflare:durable:alarm", this)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
async webSocketMessage(client, message) {
|
|
65
|
+
if (import.meta._websocket) {
|
|
66
|
+
return ws.handleDurableMessage(this, client, message);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async webSocketClose(client, code, reason, wasClean) {
|
|
70
|
+
if (import.meta._websocket) {
|
|
71
|
+
return ws.handleDurableClose(this, client, code, reason, wasClean);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import type { fetch } from "@cloudflare/workers-types";
|
|
3
|
+
interface Env {
|
|
4
|
+
ASSETS?: {
|
|
5
|
+
fetch: typeof fetch;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
declare const _default: import("@cloudflare/workers-types").ExportedHandler<Env, unknown, unknown>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import wsAdapter from "crossws/adapters/cloudflare";
|
|
3
|
+
import { useNitroApp } from "nitro/runtime";
|
|
4
|
+
import { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
|
|
5
|
+
import { createHandler } from "./_module-handler.mjs";
|
|
6
|
+
const nitroApp = useNitroApp();
|
|
7
|
+
const ws = import.meta._websocket ? (
|
|
8
|
+
// @ts-expect-error
|
|
9
|
+
wsAdapter(nitroApp.h3App.websocket)
|
|
10
|
+
) : void 0;
|
|
11
|
+
export default createHandler({
|
|
12
|
+
fetch(request, env, context, url) {
|
|
13
|
+
if (env.ASSETS && isPublicAssetURL(url.pathname)) {
|
|
14
|
+
return env.ASSETS.fetch(request);
|
|
15
|
+
}
|
|
16
|
+
if (import.meta._websocket && request.headers.get("upgrade") === "websocket") {
|
|
17
|
+
return ws.handleUpgrade(request, env, context);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import type { Request as CFRequest, EventContext, ExecutionContext } from "@cloudflare/workers-types";
|
|
3
|
+
/**
|
|
4
|
+
* Reference: https://developers.cloudflare.com/workers/runtime-apis/fetch-event/#parameters
|
|
5
|
+
*/
|
|
6
|
+
interface CFPagesEnv {
|
|
7
|
+
ASSETS: {
|
|
8
|
+
fetch: (request: CFRequest) => Promise<Response>;
|
|
9
|
+
};
|
|
10
|
+
CF_PAGES: "1";
|
|
11
|
+
CF_PAGES_BRANCH: string;
|
|
12
|
+
CF_PAGES_COMMIT_SHA: string;
|
|
13
|
+
CF_PAGES_URL: string;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
declare const _default: {
|
|
17
|
+
fetch(cfReq: CFRequest, env: CFPagesEnv, context: EventContext<CFPagesEnv, string, any>): Promise<any>;
|
|
18
|
+
scheduled(event: any, env: CFPagesEnv, context: ExecutionContext): void;
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import { useNitroApp } from "nitro/runtime";
|
|
3
|
+
import { runCronTasks } from "nitro/runtime/internal";
|
|
4
|
+
import { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
|
|
5
|
+
import wsAdapter from "crossws/adapters/cloudflare";
|
|
6
|
+
const nitroApp = useNitroApp();
|
|
7
|
+
const ws = import.meta._websocket ? (
|
|
8
|
+
// @ts-expect-error
|
|
9
|
+
wsAdapter(nitroApp.h3App.websocket)
|
|
10
|
+
) : void 0;
|
|
11
|
+
export default {
|
|
12
|
+
async fetch(cfReq, env, context) {
|
|
13
|
+
const req = cfReq;
|
|
14
|
+
req.runtime ??= { name: "cloudflare" };
|
|
15
|
+
req.runtime.cloudflare ??= { context, env };
|
|
16
|
+
req.waitUntil = context.waitUntil.bind(context);
|
|
17
|
+
if (import.meta._websocket && cfReq.headers.get("upgrade") === "websocket") {
|
|
18
|
+
return ws.handleUpgrade(
|
|
19
|
+
cfReq,
|
|
20
|
+
env,
|
|
21
|
+
context
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
const url = new URL(cfReq.url);
|
|
25
|
+
if (env.ASSETS && isPublicAssetURL(url.pathname)) {
|
|
26
|
+
return env.ASSETS.fetch(cfReq);
|
|
27
|
+
}
|
|
28
|
+
globalThis.__env__ = env;
|
|
29
|
+
return nitroApp.fetch(req);
|
|
30
|
+
},
|
|
31
|
+
scheduled(event, env, context) {
|
|
32
|
+
if (import.meta._tasks) {
|
|
33
|
+
globalThis.__env__ = env;
|
|
34
|
+
context.waitUntil(
|
|
35
|
+
runCronTasks(event.cron, {
|
|
36
|
+
context: {
|
|
37
|
+
cloudflare: {
|
|
38
|
+
env,
|
|
39
|
+
context
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
payload: {}
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const _proxy = _getPlatformProxy().catch((error) => {
|
|
2
|
+
console.error("Failed to initialize wrangler bindings proxy", error);
|
|
3
|
+
return _createStubProxy();
|
|
4
|
+
}).then((proxy) => {
|
|
5
|
+
globalThis.__env__ = proxy.env;
|
|
6
|
+
return proxy;
|
|
7
|
+
});
|
|
8
|
+
globalThis.__env__ = _proxy.then((proxy) => proxy.env);
|
|
9
|
+
export default (function(nitroApp) {
|
|
10
|
+
nitroApp.hooks.hook("request", async (event) => {
|
|
11
|
+
event.req.context ??= {};
|
|
12
|
+
const proxy = await _proxy;
|
|
13
|
+
event.req.context.cf = proxy.cf;
|
|
14
|
+
event.req.context.waitUntil = proxy.ctx.waitUntil.bind(proxy.ctx);
|
|
15
|
+
const request = new Request(event.req.url);
|
|
16
|
+
request.cf = proxy.cf;
|
|
17
|
+
event.req.context.cloudflare = {
|
|
18
|
+
...event.req.context.cloudflare,
|
|
19
|
+
request,
|
|
20
|
+
env: proxy.env,
|
|
21
|
+
context: proxy.ctx
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
nitroApp.hooks._hooks.request.unshift(nitroApp.hooks._hooks.request.pop());
|
|
25
|
+
nitroApp.hooks.hook("close", () => {
|
|
26
|
+
return _proxy?.then((proxy) => proxy.dispose);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
async function _getPlatformProxy() {
|
|
30
|
+
const { useRuntimeConfig } = await import("nitro/runtime");
|
|
31
|
+
const pkg = "wrangler";
|
|
32
|
+
const { getPlatformProxy } = await import(
|
|
33
|
+
/* @vite-ignore */
|
|
34
|
+
pkg
|
|
35
|
+
).catch(
|
|
36
|
+
() => {
|
|
37
|
+
throw new Error(
|
|
38
|
+
"Package `wrangler` not found, please install it with: `npx nypm@latest add -D wrangler`"
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
const runtimeConfig = useRuntimeConfig();
|
|
43
|
+
const proxyOptions = {
|
|
44
|
+
configPath: runtimeConfig.wrangler.configPath,
|
|
45
|
+
persist: { path: runtimeConfig.wrangler.persistDir }
|
|
46
|
+
};
|
|
47
|
+
if (runtimeConfig.wrangler.environment) {
|
|
48
|
+
proxyOptions.environment = runtimeConfig.wrangler.environment;
|
|
49
|
+
}
|
|
50
|
+
const proxy = await getPlatformProxy(proxyOptions);
|
|
51
|
+
return proxy;
|
|
52
|
+
}
|
|
53
|
+
function _createStubProxy() {
|
|
54
|
+
return {
|
|
55
|
+
env: {},
|
|
56
|
+
cf: {},
|
|
57
|
+
ctx: {
|
|
58
|
+
waitUntil() {
|
|
59
|
+
},
|
|
60
|
+
passThroughOnException() {
|
|
61
|
+
},
|
|
62
|
+
props: {}
|
|
63
|
+
},
|
|
64
|
+
caches: {
|
|
65
|
+
open() {
|
|
66
|
+
const result = Promise.resolve(new _CacheStub());
|
|
67
|
+
return result;
|
|
68
|
+
},
|
|
69
|
+
get default() {
|
|
70
|
+
return new _CacheStub();
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
dispose: () => Promise.resolve()
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
class _CacheStub {
|
|
77
|
+
delete() {
|
|
78
|
+
const result = Promise.resolve(false);
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
match() {
|
|
82
|
+
const result = Promise.resolve(void 0);
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
put() {
|
|
86
|
+
const result = Promise.resolve();
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import { useNitroApp } from "nitro/runtime";
|
|
3
|
+
import wsAdapter from "crossws/adapters/deno";
|
|
4
|
+
const nitroApp = useNitroApp();
|
|
5
|
+
const ws = import.meta._websocket ? (
|
|
6
|
+
// @ts-expect-error
|
|
7
|
+
wsAdapter(nitroApp.h3App.websocket)
|
|
8
|
+
) : void 0;
|
|
9
|
+
Deno.serve((denoReq, info) => {
|
|
10
|
+
const req = denoReq;
|
|
11
|
+
req.runtime ??= { name: "deno" };
|
|
12
|
+
req.runtime.deno ??= { info };
|
|
13
|
+
if (import.meta._websocket && req.headers.get("upgrade") === "websocket") {
|
|
14
|
+
return ws.handleUpgrade(req, info);
|
|
15
|
+
}
|
|
16
|
+
return nitroApp.fetch(req);
|
|
17
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import "#nitro-internal-pollyfills";
|
|
2
|
+
import { useNitroApp } from "nitro/runtime";
|
|
3
|
+
import { useRuntimeConfig } from "nitro/runtime";
|
|
4
|
+
import { startScheduleRunner } from "nitro/runtime/internal";
|
|
5
|
+
import wsAdapter from "crossws/adapters/deno";
|
|
6
|
+
import destr from "destr";
|
|
7
|
+
const nitroApp = useNitroApp();
|
|
8
|
+
if (Deno.env.get("DEBUG")) {
|
|
9
|
+
addEventListener(
|
|
10
|
+
"unhandledrejection",
|
|
11
|
+
(event) => console.error("[unhandledRejection]", event.reason)
|
|
12
|
+
);
|
|
13
|
+
addEventListener(
|
|
14
|
+
"error",
|
|
15
|
+
(event) => console.error("[uncaughtException]", event.error)
|
|
16
|
+
);
|
|
17
|
+
} else {
|
|
18
|
+
addEventListener(
|
|
19
|
+
"unhandledrejection",
|
|
20
|
+
(err) => console.error("[unhandledRejection] " + err)
|
|
21
|
+
);
|
|
22
|
+
addEventListener(
|
|
23
|
+
"error",
|
|
24
|
+
(event) => console.error("[uncaughtException] " + event.error)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const serveOptions = {
|
|
28
|
+
key: Deno.env.get("NITRO_SSL_KEY"),
|
|
29
|
+
cert: Deno.env.get("NITRO_SSL_CERT"),
|
|
30
|
+
port: destr(Deno.env.get("NITRO_PORT") || Deno.env.get("PORT")) || 3e3,
|
|
31
|
+
hostname: Deno.env.get("NITRO_HOST") || Deno.env.get("HOST"),
|
|
32
|
+
onListen: (opts) => {
|
|
33
|
+
const baseURL = (useRuntimeConfig().app.baseURL || "").replace(/\/$/, "");
|
|
34
|
+
const url = `${opts.hostname}:${opts.port}${baseURL}`;
|
|
35
|
+
console.log(`Listening ${url}`);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
if (!serveOptions.key || !serveOptions.cert) {
|
|
39
|
+
delete serveOptions.key;
|
|
40
|
+
delete serveOptions.cert;
|
|
41
|
+
}
|
|
42
|
+
Deno.serve(serveOptions, handler);
|
|
43
|
+
const ws = import.meta._websocket ? (
|
|
44
|
+
// @ts-expect-error
|
|
45
|
+
wsAdapter(nitroApp.h3App.websocket)
|
|
46
|
+
) : void 0;
|
|
47
|
+
async function handler(denoReq, info) {
|
|
48
|
+
const req = denoReq;
|
|
49
|
+
req.runtime ??= { name: "deno" };
|
|
50
|
+
req.runtime.deno ??= { info };
|
|
51
|
+
if (import.meta._websocket && req.headers.get("upgrade") === "websocket") {
|
|
52
|
+
return ws.handleUpgrade(req, info);
|
|
53
|
+
}
|
|
54
|
+
return nitroApp.fetch(req);
|
|
55
|
+
}
|
|
56
|
+
if (import.meta._tasks) {
|
|
57
|
+
startScheduleRunner();
|
|
58
|
+
}
|
|
59
|
+
export default {};
|