nitropack-nightly 2.10.0-28638494.93d002b7 → 3.0.0-beta-28638629.b32e0831-nitro-nightly-mirror
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/README.md +1 -1
- package/cli.d.ts +1 -1
- package/config.d.ts +1 -1
- package/core.d.ts +1 -1
- package/dist/cli/index.d.mts +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.mjs +1 -18
- package/dist/config/index.d.mts +1 -6
- package/dist/config/index.d.ts +1 -6
- package/dist/config/index.mjs +1 -5
- package/dist/core/index.d.mts +1 -69
- package/dist/core/index.d.ts +1 -69
- package/dist/core/index.mjs +1 -2435
- package/dist/kit/index.d.mts +1 -44
- package/dist/kit/index.d.ts +1 -44
- package/dist/kit/index.mjs +1 -71
- package/dist/meta/index.d.mts +1 -3
- package/dist/meta/index.d.ts +1 -3
- package/dist/meta/index.mjs +1 -3
- package/dist/presets/index.d.mts +1 -1
- package/dist/presets/index.d.ts +1 -2
- package/dist/presets/index.mjs +1 -1
- package/dist/rollup/index.d.mts +1 -5
- package/dist/rollup/index.d.ts +1 -5
- package/dist/rollup/index.mjs +1 -2033
- package/dist/runtime/index.d.mts +1 -0
- package/dist/runtime/index.d.ts +1 -12
- package/dist/runtime/index.mjs +1 -17
- package/dist/types/index.d.mts +1 -260
- package/dist/types/index.d.ts +1 -260
- package/dist/types/index.mjs +1 -1
- package/kit.d.ts +1 -1
- package/meta.d.ts +1 -1
- package/package.json +6 -172
- package/presets.d.ts +1 -1
- package/rollup.d.ts +1 -1
- package/runtime-meta.d.ts +1 -4
- package/runtime-meta.mjs +1 -30
- package/runtime.d.ts +1 -1
- package/types.d.ts +1 -1
- package/dist/cli/build.mjs +0 -47
- package/dist/cli/common.mjs +0 -13
- package/dist/cli/dev.mjs +0 -63
- package/dist/cli/index2.mjs +0 -14
- package/dist/cli/list.mjs +0 -28
- package/dist/cli/prepare.mjs +0 -21
- package/dist/cli/run.mjs +0 -57
- package/dist/presets/_all.gen.d.ts +0 -2
- package/dist/presets/_all.gen.mjs +0 -52
- package/dist/presets/_nitro/base-worker.d.ts +0 -2
- package/dist/presets/_nitro/base-worker.mjs +0 -25
- package/dist/presets/_nitro/nitro-dev.d.ts +0 -2
- package/dist/presets/_nitro/nitro-dev.mjs +0 -19
- package/dist/presets/_nitro/nitro-prerender.d.ts +0 -2
- package/dist/presets/_nitro/nitro-prerender.mjs +0 -17
- package/dist/presets/_nitro/preset.d.ts +0 -2
- package/dist/presets/_nitro/preset.mjs +0 -5
- package/dist/presets/_nitro/runtime/nitro-dev.d.ts +0 -1
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +0 -86
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.ts +0 -3
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +0 -7
- package/dist/presets/_nitro/runtime/service-worker.d.ts +0 -1
- package/dist/presets/_nitro/runtime/service-worker.mjs +0 -31
- package/dist/presets/_nitro/service-worker.d.ts +0 -2
- package/dist/presets/_nitro/service-worker.mjs +0 -110
- package/dist/presets/_resolve.d.ts +0 -8
- package/dist/presets/_resolve.mjs +0 -44
- package/dist/presets/_static/preset.d.ts +0 -2
- package/dist/presets/_static/preset.mjs +0 -69
- package/dist/presets/_types.gen.d.ts +0 -16
- package/dist/presets/_types.gen.mjs +0 -0
- package/dist/presets/alwaysdata/preset.d.ts +0 -2
- package/dist/presets/alwaysdata/preset.mjs +0 -14
- package/dist/presets/aws-amplify/preset.d.ts +0 -3
- package/dist/presets/aws-amplify/preset.mjs +0 -27
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.ts +0 -1
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +0 -13
- package/dist/presets/aws-amplify/types.d.ts +0 -141
- package/dist/presets/aws-amplify/types.mjs +0 -0
- package/dist/presets/aws-amplify/utils.d.ts +0 -2
- package/dist/presets/aws-amplify/utils.mjs +0 -82
- package/dist/presets/aws-lambda/preset.d.ts +0 -2
- package/dist/presets/aws-lambda/preset.mjs +0 -21
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.ts +0 -15
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +0 -53
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.ts +0 -4
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +0 -45
- package/dist/presets/azure/preset.d.ts +0 -3
- package/dist/presets/azure/preset.mjs +0 -44
- package/dist/presets/azure/runtime/azure-functions.d.ts +0 -5
- package/dist/presets/azure/runtime/azure-functions.mjs +0 -24
- package/dist/presets/azure/runtime/azure-swa.d.ts +0 -5
- package/dist/presets/azure/runtime/azure-swa.mjs +0 -30
- package/dist/presets/azure/types.d.ts +0 -13
- package/dist/presets/azure/types.mjs +0 -0
- package/dist/presets/azure/utils.d.ts +0 -3
- package/dist/presets/azure/utils.mjs +0 -183
- package/dist/presets/bun/preset.d.ts +0 -2
- package/dist/presets/bun/preset.mjs +0 -17
- package/dist/presets/bun/runtime/bun.d.ts +0 -1
- package/dist/presets/bun/runtime/bun.mjs +0 -32
- package/dist/presets/cleavr/preset.d.ts +0 -2
- package/dist/presets/cleavr/preset.mjs +0 -12
- package/dist/presets/cloudflare/preset.d.ts +0 -3
- package/dist/presets/cloudflare/preset.mjs +0 -145
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.ts +0 -13
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +0 -102
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.ts +0 -20
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +0 -55
- package/dist/presets/cloudflare/runtime/cloudflare-worker.d.ts +0 -1
- package/dist/presets/cloudflare/runtime/cloudflare-worker.mjs +0 -63
- package/dist/presets/cloudflare/types.d.ts +0 -89
- package/dist/presets/cloudflare/types.mjs +0 -0
- package/dist/presets/cloudflare/types.wrangler.d.ts +0 -974
- package/dist/presets/cloudflare/types.wrangler.mjs +0 -0
- package/dist/presets/cloudflare/utils.d.ts +0 -3
- package/dist/presets/cloudflare/utils.mjs +0 -163
- package/dist/presets/deno/preset.d.ts +0 -2
- package/dist/presets/deno/preset.mjs +0 -148
- package/dist/presets/deno/runtime/_deno-env-polyfill.d.ts +0 -0
- package/dist/presets/deno/runtime/_deno-env-polyfill.mjs +0 -1
- package/dist/presets/deno/runtime/deno-deploy.d.ts +0 -2
- package/dist/presets/deno/runtime/deno-deploy.mjs +0 -32
- package/dist/presets/deno/runtime/deno-server.d.ts +0 -4
- package/dist/presets/deno/runtime/deno-server.mjs +0 -66
- package/dist/presets/digitalocean/preset.d.ts +0 -2
- package/dist/presets/digitalocean/preset.mjs +0 -11
- package/dist/presets/edgio/preset.d.ts +0 -2
- package/dist/presets/edgio/preset.mjs +0 -95
- package/dist/presets/firebase/preset.d.ts +0 -3
- package/dist/presets/firebase/preset.mjs +0 -51
- package/dist/presets/firebase/runtime/firebase-gen-1.d.ts +0 -2
- package/dist/presets/firebase/runtime/firebase-gen-1.mjs +0 -8
- package/dist/presets/firebase/runtime/firebase-gen-2.d.ts +0 -2
- package/dist/presets/firebase/runtime/firebase-gen-2.mjs +0 -15
- package/dist/presets/firebase/runtime/firebase-gen-default.d.ts +0 -1
- package/dist/presets/firebase/runtime/firebase-gen-default.mjs +0 -1
- package/dist/presets/firebase/types.d.ts +0 -37
- package/dist/presets/firebase/types.mjs +0 -0
- package/dist/presets/firebase/utils.d.ts +0 -3
- package/dist/presets/firebase/utils.mjs +0 -50
- package/dist/presets/flightcontrol/preset.d.ts +0 -2
- package/dist/presets/flightcontrol/preset.mjs +0 -11
- package/dist/presets/heroku/preset.d.ts +0 -2
- package/dist/presets/heroku/preset.mjs +0 -11
- package/dist/presets/iis/preset.d.ts +0 -2
- package/dist/presets/iis/preset.mjs +0 -32
- package/dist/presets/iis/utils.d.ts +0 -3
- package/dist/presets/iis/utils.mjs +0 -159
- package/dist/presets/koyeb/preset.d.ts +0 -2
- package/dist/presets/koyeb/preset.mjs +0 -11
- package/dist/presets/netlify/legacy/preset.d.ts +0 -2
- package/dist/presets/netlify/legacy/preset.mjs +0 -142
- package/dist/presets/netlify/legacy/runtime/_deno-env-polyfill.d.ts +0 -0
- package/dist/presets/netlify/legacy/runtime/_deno-env-polyfill.mjs +0 -1
- package/dist/presets/netlify/legacy/runtime/netlify-builder.d.ts +0 -3
- package/dist/presets/netlify/legacy/runtime/netlify-builder.mjs +0 -5
- package/dist/presets/netlify/legacy/runtime/netlify-edge.d.ts +0 -3
- package/dist/presets/netlify/legacy/runtime/netlify-edge.mjs +0 -26
- package/dist/presets/netlify/legacy/runtime/netlify-lambda.d.ts +0 -4
- package/dist/presets/netlify/legacy/runtime/netlify-lambda.mjs +0 -39
- package/dist/presets/netlify/legacy/runtime/netlify.d.ts +0 -4
- package/dist/presets/netlify/legacy/runtime/netlify.mjs +0 -22
- package/dist/presets/netlify/legacy/utils.d.ts +0 -4
- package/dist/presets/netlify/legacy/utils.mjs +0 -113
- package/dist/presets/netlify/preset.d.ts +0 -3
- package/dist/presets/netlify/preset.mjs +0 -127
- package/dist/presets/netlify/runtime/_deno-env-polyfill.d.ts +0 -0
- package/dist/presets/netlify/runtime/_deno-env-polyfill.mjs +0 -1
- package/dist/presets/netlify/runtime/netlify-edge.d.ts +0 -2
- package/dist/presets/netlify/runtime/netlify-edge.mjs +0 -25
- package/dist/presets/netlify/runtime/netlify.d.ts +0 -4
- package/dist/presets/netlify/runtime/netlify.mjs +0 -54
- package/dist/presets/netlify/types.d.ts +0 -12
- package/dist/presets/netlify/types.mjs +0 -0
- package/dist/presets/netlify/utils.d.ts +0 -5
- package/dist/presets/netlify/utils.mjs +0 -94
- package/dist/presets/node/preset.d.ts +0 -2
- package/dist/presets/node/preset.mjs +0 -49
- package/dist/presets/node/runtime/cli.d.ts +0 -1
- package/dist/presets/node/runtime/cli.mjs +0 -21
- package/dist/presets/node/runtime/cluster.d.ts +0 -1
- package/dist/presets/node/runtime/cluster.mjs +0 -60
- package/dist/presets/node/runtime/node-listener.d.ts +0 -6
- package/dist/presets/node/runtime/node-listener.mjs +0 -15
- package/dist/presets/node/runtime/node-server.d.ts +0 -3
- package/dist/presets/node/runtime/node-server.mjs +0 -44
- package/dist/presets/platform.sh/preset.d.ts +0 -2
- package/dist/presets/platform.sh/preset.mjs +0 -11
- package/dist/presets/render.com/preset.d.ts +0 -2
- package/dist/presets/render.com/preset.mjs +0 -11
- package/dist/presets/stormkit/preset.d.ts +0 -2
- package/dist/presets/stormkit/preset.mjs +0 -15
- package/dist/presets/stormkit/runtime/stormkit.d.ts +0 -21
- package/dist/presets/stormkit/runtime/stormkit.mjs +0 -32
- package/dist/presets/vercel/preset.d.ts +0 -3
- package/dist/presets/vercel/preset.mjs +0 -104
- package/dist/presets/vercel/runtime/vercel-edge.d.ts +0 -2
- package/dist/presets/vercel/runtime/vercel-edge.mjs +0 -22
- package/dist/presets/vercel/runtime/vercel.d.ts +0 -4
- package/dist/presets/vercel/runtime/vercel.mjs +0 -17
- package/dist/presets/vercel/types.d.ts +0 -78
- package/dist/presets/vercel/types.mjs +0 -0
- package/dist/presets/vercel/utils.d.ts +0 -5
- package/dist/presets/vercel/utils.mjs +0 -186
- package/dist/presets/winterjs/preset.d.ts +0 -2
- package/dist/presets/winterjs/preset.mjs +0 -20
- package/dist/presets/winterjs/runtime/winterjs.d.ts +0 -1
- package/dist/presets/winterjs/runtime/winterjs.mjs +0 -69
- package/dist/presets/zeabur/preset.d.ts +0 -2
- package/dist/presets/zeabur/preset.mjs +0 -70
- package/dist/presets/zeabur/runtime/zeabur.d.ts +0 -4
- package/dist/presets/zeabur/runtime/zeabur.mjs +0 -8
- package/dist/runtime/app.d.ts +0 -2
- package/dist/runtime/app.mjs +0 -1
- package/dist/runtime/cache.d.ts +0 -1
- package/dist/runtime/cache.mjs +0 -6
- package/dist/runtime/config.d.ts +0 -1
- package/dist/runtime/config.mjs +0 -1
- package/dist/runtime/context.d.ts +0 -1
- package/dist/runtime/context.mjs +0 -1
- package/dist/runtime/database.d.ts +0 -1
- package/dist/runtime/database.mjs +0 -1
- package/dist/runtime/error.d.ts +0 -1
- package/dist/runtime/error.mjs +0 -1
- package/dist/runtime/internal/app.d.ts +0 -3
- package/dist/runtime/internal/app.mjs +0 -152
- package/dist/runtime/internal/cache.d.ts +0 -8
- package/dist/runtime/internal/cache.mjs +0 -329
- package/dist/runtime/internal/client.d.ts +0 -1
- package/dist/runtime/internal/client.mjs +0 -4
- package/dist/runtime/internal/config.d.ts +0 -6
- package/dist/runtime/internal/config.mjs +0 -58
- package/dist/runtime/internal/context.d.ts +0 -12
- package/dist/runtime/internal/context.mjs +0 -17
- package/dist/runtime/internal/database.d.ts +0 -2
- package/dist/runtime/internal/database.mjs +0 -14
- package/dist/runtime/internal/debug.d.ts +0 -2
- package/dist/runtime/internal/debug.mjs +0 -5
- package/dist/runtime/internal/error.d.ts +0 -4
- package/dist/runtime/internal/error.mjs +0 -71
- package/dist/runtime/internal/index.d.ts +0 -6
- package/dist/runtime/internal/index.mjs +0 -16
- package/dist/runtime/internal/lib/http-graceful-shutdown.d.ts +0 -16
- package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +0 -213
- package/dist/runtime/internal/meta.d.ts +0 -2
- package/dist/runtime/internal/meta.mjs +0 -3
- package/dist/runtime/internal/plugin.d.ts +0 -3
- package/dist/runtime/internal/plugin.mjs +0 -4
- package/dist/runtime/internal/renderer.d.ts +0 -2
- package/dist/runtime/internal/renderer.mjs +0 -38
- package/dist/runtime/internal/route-rules.d.ts +0 -14
- package/dist/runtime/internal/route-rules.mjs +0 -67
- package/dist/runtime/internal/routes/openapi.d.ts +0 -3
- package/dist/runtime/internal/routes/openapi.mjs +0 -85
- package/dist/runtime/internal/routes/scalar.d.ts +0 -2
- package/dist/runtime/internal/routes/scalar.mjs +0 -191
- package/dist/runtime/internal/routes/swagger.d.ts +0 -2
- package/dist/runtime/internal/routes/swagger.mjs +0 -39
- package/dist/runtime/internal/shutdown.d.ts +0 -10
- package/dist/runtime/internal/shutdown.mjs +0 -34
- package/dist/runtime/internal/static.d.ts +0 -2
- package/dist/runtime/internal/static.mjs +0 -89
- package/dist/runtime/internal/storage.d.ts +0 -2
- package/dist/runtime/internal/storage.mjs +0 -5
- package/dist/runtime/internal/task.d.ts +0 -17
- package/dist/runtime/internal/task.mjs +0 -73
- package/dist/runtime/internal/timing.d.ts +0 -2
- package/dist/runtime/internal/timing.mjs +0 -29
- package/dist/runtime/internal/utils.azure.d.ts +0 -2
- package/dist/runtime/internal/utils.azure.mjs +0 -51
- package/dist/runtime/internal/utils.d.ts +0 -23
- package/dist/runtime/internal/utils.env.d.ts +0 -7
- package/dist/runtime/internal/utils.env.mjs +0 -39
- package/dist/runtime/internal/utils.lambda.d.ts +0 -12
- package/dist/runtime/internal/utils.lambda.mjs +0 -30
- package/dist/runtime/internal/utils.mjs +0 -129
- package/dist/runtime/plugin.d.ts +0 -1
- package/dist/runtime/plugin.mjs +0 -1
- package/dist/runtime/storage.d.ts +0 -1
- package/dist/runtime/storage.mjs +0 -1
- package/dist/runtime/task.d.ts +0 -1
- package/dist/runtime/task.mjs +0 -1
- package/dist/runtime/utils.d.ts +0 -1
- package/dist/runtime/utils.mjs +0 -1
- package/dist/shared/nitro.DkCt8MDS.d.mts +0 -588
- package/dist/shared/nitro.DkCt8MDS.d.ts +0 -588
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { klona } from "klona";
|
|
2
|
-
import { applyEnv } from "./utils.env.mjs";
|
|
3
|
-
import { appConfig as _inlineAppConfig } from "#nitro-internal-virtual/app-config";
|
|
4
|
-
const _inlineRuntimeConfig = process.env.RUNTIME_CONFIG;
|
|
5
|
-
const envOptions = {
|
|
6
|
-
prefix: "NITRO_",
|
|
7
|
-
altPrefix: _inlineRuntimeConfig.nitro.envPrefix ?? process.env.NITRO_ENV_PREFIX ?? "_",
|
|
8
|
-
envExpansion: _inlineRuntimeConfig.nitro.envExpansion ?? process.env.NITRO_ENV_EXPANSION ?? false
|
|
9
|
-
};
|
|
10
|
-
const _sharedRuntimeConfig = _deepFreeze(
|
|
11
|
-
applyEnv(klona(_inlineRuntimeConfig), envOptions)
|
|
12
|
-
);
|
|
13
|
-
export function useRuntimeConfig(event) {
|
|
14
|
-
if (!event) {
|
|
15
|
-
return _sharedRuntimeConfig;
|
|
16
|
-
}
|
|
17
|
-
if (event.context.nitro.runtimeConfig) {
|
|
18
|
-
return event.context.nitro.runtimeConfig;
|
|
19
|
-
}
|
|
20
|
-
const runtimeConfig = klona(_inlineRuntimeConfig);
|
|
21
|
-
applyEnv(runtimeConfig, envOptions);
|
|
22
|
-
event.context.nitro.runtimeConfig = runtimeConfig;
|
|
23
|
-
return runtimeConfig;
|
|
24
|
-
}
|
|
25
|
-
const _sharedAppConfig = _deepFreeze(klona(_inlineAppConfig));
|
|
26
|
-
export function useAppConfig(event) {
|
|
27
|
-
if (!event) {
|
|
28
|
-
return _sharedAppConfig;
|
|
29
|
-
}
|
|
30
|
-
if (event.context.nitro.appConfig) {
|
|
31
|
-
return event.context.nitro.appConfig;
|
|
32
|
-
}
|
|
33
|
-
const appConfig = klona(_inlineAppConfig);
|
|
34
|
-
event.context.nitro.appConfig = appConfig;
|
|
35
|
-
return appConfig;
|
|
36
|
-
}
|
|
37
|
-
function _deepFreeze(object) {
|
|
38
|
-
const propNames = Object.getOwnPropertyNames(object);
|
|
39
|
-
for (const name of propNames) {
|
|
40
|
-
const value = object[name];
|
|
41
|
-
if (value && typeof value === "object") {
|
|
42
|
-
_deepFreeze(value);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return Object.freeze(object);
|
|
46
|
-
}
|
|
47
|
-
export default new Proxy(/* @__PURE__ */ Object.create(null), {
|
|
48
|
-
get: (_, prop) => {
|
|
49
|
-
console.warn(
|
|
50
|
-
"Please use `useRuntimeConfig()` instead of accessing config directly."
|
|
51
|
-
);
|
|
52
|
-
const runtimeConfig = useRuntimeConfig();
|
|
53
|
-
if (prop in runtimeConfig) {
|
|
54
|
-
return runtimeConfig[prop];
|
|
55
|
-
}
|
|
56
|
-
return void 0;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { H3Event } from "h3";
|
|
2
|
-
export declare const nitroAsyncContext: import("unctx/index").UseContext<NitroAsyncContext>;
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* Access to the current Nitro request event.
|
|
6
|
-
*
|
|
7
|
-
* @experimental
|
|
8
|
-
* - Requires `experimental.asyncContext: true` config to work.
|
|
9
|
-
* - Works in Node.js and limited runtimes only
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
export declare function useEvent(): H3Event;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import { createError } from "h3";
|
|
3
|
-
import { getContext } from "unctx";
|
|
4
|
-
export const nitroAsyncContext = getContext("nitro-app", {
|
|
5
|
-
asyncContext: import.meta._asyncContext,
|
|
6
|
-
AsyncLocalStorage: import.meta._asyncContext ? AsyncLocalStorage : void 0
|
|
7
|
-
});
|
|
8
|
-
export function useEvent() {
|
|
9
|
-
try {
|
|
10
|
-
return nitroAsyncContext.use().event;
|
|
11
|
-
} catch {
|
|
12
|
-
const hint = import.meta._asyncContext ? "Note: This is an experimental feature and might be broken on non-Node.js environments." : "Enable the experimental flag using `experimental.asyncContext: true`.";
|
|
13
|
-
throw createError({
|
|
14
|
-
message: `Nitro request context is not available. ${hint}`
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createDatabase } from "db0";
|
|
2
|
-
import { connectionConfigs } from "#nitro-internal-virtual/database";
|
|
3
|
-
const instances = /* @__PURE__ */ Object.create(null);
|
|
4
|
-
export function useDatabase(name = "default") {
|
|
5
|
-
if (instances[name]) {
|
|
6
|
-
return instances[name];
|
|
7
|
-
}
|
|
8
|
-
if (!connectionConfigs[name]) {
|
|
9
|
-
throw new Error(`Database connection "${name}" not configured.`);
|
|
10
|
-
}
|
|
11
|
-
return instances[name] = createDatabase(
|
|
12
|
-
connectionConfigs[name].connector(connectionConfigs[name].options || {})
|
|
13
|
-
);
|
|
14
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { setResponseHeader, setResponseStatus, send } from "h3";
|
|
2
|
-
import { normalizeError, isJsonRequest } from "./utils.mjs";
|
|
3
|
-
export function defineNitroErrorHandler(handler) {
|
|
4
|
-
return handler;
|
|
5
|
-
}
|
|
6
|
-
const isDev = process.env.NODE_ENV === "development";
|
|
7
|
-
export default defineNitroErrorHandler(
|
|
8
|
-
function defaultNitroErrorHandler(error, event) {
|
|
9
|
-
const { stack, statusCode, statusMessage, message } = normalizeError(error);
|
|
10
|
-
const showDetails = isDev && statusCode !== 404;
|
|
11
|
-
const errorObject = {
|
|
12
|
-
url: event.path || "",
|
|
13
|
-
statusCode,
|
|
14
|
-
statusMessage,
|
|
15
|
-
message,
|
|
16
|
-
stack: showDetails ? stack.map((i) => i.text) : void 0
|
|
17
|
-
};
|
|
18
|
-
if (error.unhandled || error.fatal) {
|
|
19
|
-
const tags = [
|
|
20
|
-
"[nitro]",
|
|
21
|
-
"[request error]",
|
|
22
|
-
error.unhandled && "[unhandled]",
|
|
23
|
-
error.fatal && "[fatal]"
|
|
24
|
-
].filter(Boolean).join(" ");
|
|
25
|
-
console.error(
|
|
26
|
-
tags,
|
|
27
|
-
error.message + "\n" + stack.map((l) => " " + l.text).join(" \n")
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
setResponseStatus(event, statusCode, statusMessage);
|
|
31
|
-
if (isJsonRequest(event)) {
|
|
32
|
-
setResponseHeader(event, "Content-Type", "application/json");
|
|
33
|
-
return send(event, JSON.stringify(errorObject));
|
|
34
|
-
} else {
|
|
35
|
-
setResponseHeader(event, "Content-Type", "text/html");
|
|
36
|
-
return send(event, renderHTMLError(errorObject));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
function renderHTMLError(error) {
|
|
41
|
-
const statusCode = error.statusCode || 500;
|
|
42
|
-
const statusMessage = error.statusMessage || "Request Error";
|
|
43
|
-
return `<!DOCTYPE html>
|
|
44
|
-
<html lang="en">
|
|
45
|
-
<head>
|
|
46
|
-
<meta charset="utf-8">
|
|
47
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
48
|
-
<title>${statusCode} ${statusMessage}</title>
|
|
49
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico/css/pico.min.css">
|
|
50
|
-
</head>
|
|
51
|
-
<body>
|
|
52
|
-
<main class="container">
|
|
53
|
-
<dialog open>
|
|
54
|
-
<article>
|
|
55
|
-
<header>
|
|
56
|
-
<h2>${statusCode} ${statusMessage}</h2>
|
|
57
|
-
</header>
|
|
58
|
-
<code>
|
|
59
|
-
${error.message}<br><br>
|
|
60
|
-
${"\n" + (error.stack || []).map((i) => ` ${i}`).join("<br>")}
|
|
61
|
-
</code>
|
|
62
|
-
<footer>
|
|
63
|
-
<a href="/" onclick="event.preventDefault();history.back();">Go Back</a>
|
|
64
|
-
</footer>
|
|
65
|
-
</article>
|
|
66
|
-
</dialog>
|
|
67
|
-
</main>
|
|
68
|
-
</body>
|
|
69
|
-
</html>
|
|
70
|
-
`;
|
|
71
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { trapUnhandledNodeErrors, normalizeCookieHeader, requestHasBody, joinHeaders, toBuffer, } from "./utils";
|
|
2
|
-
export { normalizeLambdaIncomingHeaders, normalizeLambdaOutgoingHeaders, normalizeLambdaOutgoingBody, } from "./utils.lambda";
|
|
3
|
-
export { startScheduleRunner, runCronTasks } from "./task";
|
|
4
|
-
export { getAzureParsedCookiesFromHeaders } from "./utils.azure";
|
|
5
|
-
export { getGracefulShutdownConfig, setupGracefulShutdown } from "./shutdown";
|
|
6
|
-
export { getRouteRulesForPath } from "./route-rules";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
trapUnhandledNodeErrors,
|
|
3
|
-
normalizeCookieHeader,
|
|
4
|
-
requestHasBody,
|
|
5
|
-
joinHeaders,
|
|
6
|
-
toBuffer
|
|
7
|
-
} from "./utils.mjs";
|
|
8
|
-
export {
|
|
9
|
-
normalizeLambdaIncomingHeaders,
|
|
10
|
-
normalizeLambdaOutgoingHeaders,
|
|
11
|
-
normalizeLambdaOutgoingBody
|
|
12
|
-
} from "./utils.lambda.mjs";
|
|
13
|
-
export { startScheduleRunner, runCronTasks } from "./task.mjs";
|
|
14
|
-
export { getAzureParsedCookiesFromHeaders } from "./utils.azure.mjs";
|
|
15
|
-
export { getGracefulShutdownConfig, setupGracefulShutdown } from "./shutdown.mjs";
|
|
16
|
-
export { getRouteRulesForPath } from "./route-rules.mjs";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gracefully shuts down `server` when the process receives
|
|
3
|
-
* the passed signals
|
|
4
|
-
*
|
|
5
|
-
* @param {http.Server} server
|
|
6
|
-
* @param {object} opts
|
|
7
|
-
* signals: string (each signal separated by SPACE)
|
|
8
|
-
* timeout: timeout value for forceful shutdown in ms
|
|
9
|
-
* forceExit: force process.exit() - otherwise just let event loop clear
|
|
10
|
-
* development: boolean value (if true, no graceful shutdown to speed up development
|
|
11
|
-
* preShutdown: optional function. Needs to return a promise. - HTTP sockets are still available and untouched
|
|
12
|
-
* onShutdown: optional function. Needs to return a promise.
|
|
13
|
-
* finally: optional function, handled at the end of the shutdown.
|
|
14
|
-
*/
|
|
15
|
-
declare function GracefulShutdown(server: any, opts: any): () => any;
|
|
16
|
-
export default GracefulShutdown;
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import http from "node:http";
|
|
2
|
-
const debug = (...args) => {
|
|
3
|
-
};
|
|
4
|
-
function GracefulShutdown(server, opts) {
|
|
5
|
-
opts = opts || {};
|
|
6
|
-
const options = Object.assign(
|
|
7
|
-
{
|
|
8
|
-
signals: "SIGINT SIGTERM",
|
|
9
|
-
timeout: 3e4,
|
|
10
|
-
development: false,
|
|
11
|
-
forceExit: true,
|
|
12
|
-
onShutdown: (signal) => Promise.resolve(signal),
|
|
13
|
-
preShutdown: (signal) => Promise.resolve(signal)
|
|
14
|
-
},
|
|
15
|
-
opts
|
|
16
|
-
);
|
|
17
|
-
let isShuttingDown = false;
|
|
18
|
-
const connections = {};
|
|
19
|
-
let connectionCounter = 0;
|
|
20
|
-
const secureConnections = {};
|
|
21
|
-
let secureConnectionCounter = 0;
|
|
22
|
-
let failed = false;
|
|
23
|
-
let finalRun = false;
|
|
24
|
-
function onceFactory() {
|
|
25
|
-
let called = false;
|
|
26
|
-
return (emitter, events, callback) => {
|
|
27
|
-
function call() {
|
|
28
|
-
if (!called) {
|
|
29
|
-
called = true;
|
|
30
|
-
return Reflect.apply(callback, this, arguments);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
for (const e of events) {
|
|
34
|
-
emitter.on(e, call);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
const signals = options.signals.split(" ").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
39
|
-
const once = onceFactory();
|
|
40
|
-
once(process, signals, (signal) => {
|
|
41
|
-
debug("received shut down signal", signal);
|
|
42
|
-
shutdown(signal).then(() => {
|
|
43
|
-
if (options.forceExit) {
|
|
44
|
-
process.exit(failed ? 1 : 0);
|
|
45
|
-
}
|
|
46
|
-
}).catch((error) => {
|
|
47
|
-
debug("server shut down error occurred", error);
|
|
48
|
-
process.exit(1);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
function isFunction(functionToCheck) {
|
|
52
|
-
const getType = Object.prototype.toString.call(functionToCheck);
|
|
53
|
-
return /^\[object\s([A-Za-z]+)?Function]$/.test(getType);
|
|
54
|
-
}
|
|
55
|
-
function destroy(socket, force = false) {
|
|
56
|
-
if (socket._isIdle && isShuttingDown || force) {
|
|
57
|
-
socket.destroy();
|
|
58
|
-
if (socket.server instanceof http.Server) {
|
|
59
|
-
delete connections[socket._connectionId];
|
|
60
|
-
} else {
|
|
61
|
-
delete secureConnections[socket._connectionId];
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function destroyAllConnections(force = false) {
|
|
66
|
-
debug("Destroy Connections : " + (force ? "forced close" : "close"));
|
|
67
|
-
let counter = 0;
|
|
68
|
-
let secureCounter = 0;
|
|
69
|
-
for (const key of Object.keys(connections)) {
|
|
70
|
-
const socket = connections[key];
|
|
71
|
-
const serverResponse = socket._httpMessage;
|
|
72
|
-
if (serverResponse && !force) {
|
|
73
|
-
if (!serverResponse.headersSent) {
|
|
74
|
-
serverResponse.setHeader("connection", "close");
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
counter++;
|
|
78
|
-
destroy(socket);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
debug("Connections destroyed : " + counter);
|
|
82
|
-
debug("Connection Counter : " + connectionCounter);
|
|
83
|
-
for (const key of Object.keys(secureConnections)) {
|
|
84
|
-
const socket = secureConnections[key];
|
|
85
|
-
const serverResponse = socket._httpMessage;
|
|
86
|
-
if (serverResponse && !force) {
|
|
87
|
-
if (!serverResponse.headersSent) {
|
|
88
|
-
serverResponse.setHeader("connection", "close");
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
secureCounter++;
|
|
92
|
-
destroy(socket);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
debug("Secure Connections destroyed : " + secureCounter);
|
|
96
|
-
debug("Secure Connection Counter : " + secureConnectionCounter);
|
|
97
|
-
}
|
|
98
|
-
server.on("request", function(req, res) {
|
|
99
|
-
req.socket._isIdle = false;
|
|
100
|
-
if (isShuttingDown && !res.headersSent) {
|
|
101
|
-
res.setHeader("connection", "close");
|
|
102
|
-
}
|
|
103
|
-
res.on("finish", function() {
|
|
104
|
-
req.socket._isIdle = true;
|
|
105
|
-
destroy(req.socket);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
server.on("connection", function(socket) {
|
|
109
|
-
if (isShuttingDown) {
|
|
110
|
-
socket.destroy();
|
|
111
|
-
} else {
|
|
112
|
-
const id = connectionCounter++;
|
|
113
|
-
socket._isIdle = true;
|
|
114
|
-
socket._connectionId = id;
|
|
115
|
-
connections[id] = socket;
|
|
116
|
-
socket.once("close", () => {
|
|
117
|
-
delete connections[socket._connectionId];
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
server.on("secureConnection", (socket) => {
|
|
122
|
-
if (isShuttingDown) {
|
|
123
|
-
socket.destroy();
|
|
124
|
-
} else {
|
|
125
|
-
const id = secureConnectionCounter++;
|
|
126
|
-
socket._isIdle = true;
|
|
127
|
-
socket._connectionId = id;
|
|
128
|
-
secureConnections[id] = socket;
|
|
129
|
-
socket.once("close", () => {
|
|
130
|
-
delete secureConnections[socket._connectionId];
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
process.on("close", function() {
|
|
135
|
-
debug("closed");
|
|
136
|
-
});
|
|
137
|
-
function shutdown(sig) {
|
|
138
|
-
function cleanupHttp() {
|
|
139
|
-
destroyAllConnections();
|
|
140
|
-
debug("Close http server");
|
|
141
|
-
return new Promise((resolve, reject) => {
|
|
142
|
-
server.close((err) => {
|
|
143
|
-
if (err) {
|
|
144
|
-
return reject(err);
|
|
145
|
-
}
|
|
146
|
-
return resolve(true);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
debug("shutdown signal - " + sig);
|
|
151
|
-
if (options.development) {
|
|
152
|
-
debug("DEV-Mode - immediate forceful shutdown");
|
|
153
|
-
return process.exit(0);
|
|
154
|
-
}
|
|
155
|
-
function finalHandler() {
|
|
156
|
-
if (!finalRun) {
|
|
157
|
-
finalRun = true;
|
|
158
|
-
if (options.finally && isFunction(options.finally)) {
|
|
159
|
-
debug("executing finally()");
|
|
160
|
-
options.finally();
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return Promise.resolve();
|
|
164
|
-
}
|
|
165
|
-
function waitForReadyToShutDown(totalNumInterval) {
|
|
166
|
-
debug(`waitForReadyToShutDown... ${totalNumInterval}`);
|
|
167
|
-
if (totalNumInterval === 0) {
|
|
168
|
-
debug(
|
|
169
|
-
`Could not close connections in time (${options.timeout}ms), will forcefully shut down`
|
|
170
|
-
);
|
|
171
|
-
return Promise.resolve(true);
|
|
172
|
-
}
|
|
173
|
-
const allConnectionsClosed = Object.keys(connections).length === 0 && Object.keys(secureConnections).length === 0;
|
|
174
|
-
if (allConnectionsClosed) {
|
|
175
|
-
debug("All connections closed. Continue to shutting down");
|
|
176
|
-
return Promise.resolve(false);
|
|
177
|
-
}
|
|
178
|
-
debug("Schedule the next waitForReadyToShutdown");
|
|
179
|
-
return new Promise((resolve) => {
|
|
180
|
-
setTimeout(() => {
|
|
181
|
-
resolve(waitForReadyToShutDown(totalNumInterval - 1));
|
|
182
|
-
}, 250);
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
if (isShuttingDown) {
|
|
186
|
-
return Promise.resolve();
|
|
187
|
-
}
|
|
188
|
-
debug("shutting down");
|
|
189
|
-
return options.preShutdown(sig).then(() => {
|
|
190
|
-
isShuttingDown = true;
|
|
191
|
-
cleanupHttp();
|
|
192
|
-
}).then(() => {
|
|
193
|
-
const pollIterations = options.timeout ? Math.round(options.timeout / 250) : 0;
|
|
194
|
-
return waitForReadyToShutDown(pollIterations);
|
|
195
|
-
}).then((force) => {
|
|
196
|
-
debug("Do onShutdown now");
|
|
197
|
-
if (force) {
|
|
198
|
-
destroyAllConnections(force);
|
|
199
|
-
}
|
|
200
|
-
return options.onShutdown(sig);
|
|
201
|
-
}).then(finalHandler).catch((error) => {
|
|
202
|
-
const errString = typeof error === "string" ? error : JSON.stringify(error);
|
|
203
|
-
debug(errString);
|
|
204
|
-
failed = true;
|
|
205
|
-
throw errString;
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
function shutdownManual() {
|
|
209
|
-
return shutdown("manual");
|
|
210
|
-
}
|
|
211
|
-
return shutdownManual;
|
|
212
|
-
}
|
|
213
|
-
export default GracefulShutdown;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
eventHandler,
|
|
3
|
-
getResponseStatus,
|
|
4
|
-
send,
|
|
5
|
-
setResponseHeader,
|
|
6
|
-
setResponseHeaders,
|
|
7
|
-
setResponseStatus
|
|
8
|
-
} from "h3";
|
|
9
|
-
import { useNitroApp } from "./app.mjs";
|
|
10
|
-
export function defineRenderHandler(handler) {
|
|
11
|
-
return eventHandler(async (event) => {
|
|
12
|
-
if (event.path.endsWith("/favicon.ico")) {
|
|
13
|
-
setResponseHeader(event, "Content-Type", "image/x-icon");
|
|
14
|
-
return send(
|
|
15
|
-
event,
|
|
16
|
-
"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
const response = await handler(event);
|
|
20
|
-
if (!response) {
|
|
21
|
-
const _currentStatus = getResponseStatus(event);
|
|
22
|
-
setResponseStatus(event, _currentStatus === 200 ? 500 : _currentStatus);
|
|
23
|
-
return send(
|
|
24
|
-
event,
|
|
25
|
-
"No response returned from render handler: " + event.path
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
const nitroApp = useNitroApp();
|
|
29
|
-
await nitroApp.hooks.callHook("render:response", response, { event });
|
|
30
|
-
if (response.headers) {
|
|
31
|
-
setResponseHeaders(event, response.headers);
|
|
32
|
-
}
|
|
33
|
-
if (response.statusCode || response.statusMessage) {
|
|
34
|
-
setResponseStatus(event, response.statusCode, response.statusMessage);
|
|
35
|
-
}
|
|
36
|
-
return response.body;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { H3Event } from "h3";
|
|
2
|
-
import type { NitroRouteRules } from "nitropack/types";
|
|
3
|
-
export declare function createRouteRulesHandler(ctx: {
|
|
4
|
-
localFetch: typeof globalThis.fetch;
|
|
5
|
-
}): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any> | undefined>;
|
|
6
|
-
export declare function getRouteRules(event: H3Event): NitroRouteRules;
|
|
7
|
-
type DeepReadonly<T> = T extends Record<string, any> ? {
|
|
8
|
-
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
9
|
-
} : T extends Array<infer U> ? ReadonlyArray<DeepReadonly<U>> : T;
|
|
10
|
-
/**
|
|
11
|
-
* @param path - The path to match against route rules. This should not contain a query string.
|
|
12
|
-
*/
|
|
13
|
-
export declare function getRouteRulesForPath(path: string): DeepReadonly<NitroRouteRules>;
|
|
14
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
eventHandler,
|
|
3
|
-
sendRedirect,
|
|
4
|
-
setHeaders,
|
|
5
|
-
proxyRequest
|
|
6
|
-
} from "h3";
|
|
7
|
-
import defu from "defu";
|
|
8
|
-
import { createRouter as createRadixRouter, toRouteMatcher } from "radix3";
|
|
9
|
-
import { joinURL, withQuery, getQuery, withoutBase } from "ufo";
|
|
10
|
-
import { useRuntimeConfig } from "./config.mjs";
|
|
11
|
-
const config = useRuntimeConfig();
|
|
12
|
-
const _routeRulesMatcher = toRouteMatcher(
|
|
13
|
-
createRadixRouter({ routes: config.nitro.routeRules })
|
|
14
|
-
);
|
|
15
|
-
export function createRouteRulesHandler(ctx) {
|
|
16
|
-
return eventHandler((event) => {
|
|
17
|
-
const routeRules = getRouteRules(event);
|
|
18
|
-
if (routeRules.headers) {
|
|
19
|
-
setHeaders(event, routeRules.headers);
|
|
20
|
-
}
|
|
21
|
-
if (routeRules.redirect) {
|
|
22
|
-
let target = routeRules.redirect.to;
|
|
23
|
-
if (target.endsWith("/**")) {
|
|
24
|
-
let targetPath = event.path;
|
|
25
|
-
const strpBase = routeRules.redirect._redirectStripBase;
|
|
26
|
-
if (strpBase) {
|
|
27
|
-
targetPath = withoutBase(targetPath, strpBase);
|
|
28
|
-
}
|
|
29
|
-
target = joinURL(target.slice(0, -3), targetPath);
|
|
30
|
-
} else if (event.path.includes("?")) {
|
|
31
|
-
const query = getQuery(event.path);
|
|
32
|
-
target = withQuery(target, query);
|
|
33
|
-
}
|
|
34
|
-
return sendRedirect(event, target, routeRules.redirect.statusCode);
|
|
35
|
-
}
|
|
36
|
-
if (routeRules.proxy) {
|
|
37
|
-
let target = routeRules.proxy.to;
|
|
38
|
-
if (target.endsWith("/**")) {
|
|
39
|
-
let targetPath = event.path;
|
|
40
|
-
const strpBase = routeRules.proxy._proxyStripBase;
|
|
41
|
-
if (strpBase) {
|
|
42
|
-
targetPath = withoutBase(targetPath, strpBase);
|
|
43
|
-
}
|
|
44
|
-
target = joinURL(target.slice(0, -3), targetPath);
|
|
45
|
-
} else if (event.path.includes("?")) {
|
|
46
|
-
const query = getQuery(event.path);
|
|
47
|
-
target = withQuery(target, query);
|
|
48
|
-
}
|
|
49
|
-
return proxyRequest(event, target, {
|
|
50
|
-
fetch: ctx.localFetch,
|
|
51
|
-
...routeRules.proxy
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
export function getRouteRules(event) {
|
|
57
|
-
event.context._nitro = event.context._nitro || {};
|
|
58
|
-
if (!event.context._nitro.routeRules) {
|
|
59
|
-
event.context._nitro.routeRules = getRouteRulesForPath(
|
|
60
|
-
withoutBase(event.path.split("?")[0], useRuntimeConfig().app.baseURL)
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
return event.context._nitro.routeRules;
|
|
64
|
-
}
|
|
65
|
-
export function getRouteRulesForPath(path) {
|
|
66
|
-
return defu({}, ..._routeRulesMatcher.matchAll(path).reverse());
|
|
67
|
-
}
|