@harlan-zw/nuxt-cloudflare 0.0.1

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.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Harlan Wilton
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # @harlan-zw/nuxt-cloudflare
2
+
3
+ Opinionated Cloudflare defaults and deploy diagnostics for Nuxt 4.
4
+
5
+ The module extracts production patterns already proven in Nuxt SEO and gscdump. It intentionally owns platform policy, not application topology.
6
+
7
+ ## Defaults
8
+
9
+ - Cloudflare module preset, generated Wrangler config, and Node compatibility
10
+ - Static assets always bypass the Worker. Any `assets.run_worker_first` declaration fails the build and `doctor`
11
+ - Workers Logs sampled at 10%, traces at 1%, both overridable
12
+ - Version metadata binding at `CF_VERSION_METADATA`
13
+ - Source-map upload when the Nitro build emits maps; explicit `false` is preserved
14
+ - `secrets.required` names only, with plaintext secret-looking `vars` rejected
15
+ - Raw `cloudflare-kv-binding` on Nitro's `cache` mount upgraded to a 30-day physical expiry
16
+ - Final generated Wrangler config audited after production Nitro compiles
17
+ - Complete defaults and diagnostics applied to every named Wrangler environment
18
+
19
+ Persistent KV mounts are never wrapped. The expiry policy applies only to cache data.
20
+
21
+ ## Setup
22
+
23
+ ```ts
24
+ export default defineNuxtConfig({
25
+ modules: ['@harlan-zw/nuxt-cloudflare'],
26
+
27
+ nuxtCloudflare: {
28
+ requiredSecrets: ['NUXT_SESSION_PASSWORD'],
29
+ },
30
+
31
+ nitro: {
32
+ storage: {
33
+ cache: { driver: 'cloudflare-kv-binding', binding: 'CACHE' },
34
+ kv: { driver: 'cloudflare-kv-binding', binding: 'KV' },
35
+ },
36
+ },
37
+ })
38
+ ```
39
+
40
+ To configure a cache mount when one does not already exist:
41
+
42
+ ```ts
43
+ export default defineNuxtConfig({
44
+ nuxtCloudflare: {
45
+ kvCache: {
46
+ binding: 'CACHE',
47
+ defaultTtl: 30 * 24 * 60 * 60,
48
+ },
49
+ },
50
+ })
51
+ ```
52
+
53
+ Cloudflare KV requires TTLs of at least 60 seconds.
54
+
55
+ ## Doctor
56
+
57
+ Audit Wrangler's effective configuration, including generated config redirects and named environments:
58
+
59
+ ```sh
60
+ pnpm nuxt-cloudflare doctor
61
+ pnpm nuxt-cloudflare doctor --env production --json
62
+ ```
63
+
64
+ Errors include worker-first assets, missing `nodejs_compat`, malformed compatibility dates, and secret-looking plaintext variables. Diagnostics report secret names only.
65
+
66
+ Recommended CI sequence:
67
+
68
+ ```sh
69
+ pnpm nuxt build
70
+ pnpm nuxt-cloudflare doctor
71
+ pnpm wrangler types --check
72
+ pnpm wrangler deploy --strict --dry-run --outdir .wrangler-dist
73
+ pnpm wrangler check startup
74
+ ```
75
+
76
+ ## Runtime primitives
77
+
78
+ ### D1 sessions and safe retries
79
+
80
+ ```ts
81
+ import { getRequestD1Session, retryIdempotentD1Write } from '@harlan-zw/nuxt-cloudflare/d1'
82
+
83
+ const session = getRequestD1Session(event.context, 'DB', event.context.cloudflare.env.DB)
84
+
85
+ await retryIdempotentD1Write({
86
+ safety: { _tag: 'replay-safe' },
87
+ run: () => session.prepare('INSERT OR IGNORE INTO jobs (id) VALUES (?)').bind(id).run(),
88
+ })
89
+ ```
90
+
91
+ One `first-primary` session is cached per request and binding. D1 already retries read-only queries. Write retries require an explicit safety tag. `lock-only` retries SQLite lock contention; `replay-safe` also permits classified transient network and reset failures.
92
+
93
+ ### Bindings
94
+
95
+ ```ts
96
+ import type { CloudflareEventLike } from '@harlan-zw/nuxt-cloudflare/bindings'
97
+ import { requireCloudflareBinding } from '@harlan-zw/nuxt-cloudflare/bindings'
98
+
99
+ function requireDatabase(event: CloudflareEventLike<Env>) {
100
+ return requireCloudflareBinding(event, 'DB')
101
+ }
102
+ ```
103
+
104
+ `Env` comes from `wrangler types`. Binding access is request-bound and binding names are constrained to `keyof Env`. Missing required bindings throw; there is no global or empty-object fallback.
105
+
106
+ ### Scoped secrets file
107
+
108
+ ```ts
109
+ import { execFile } from 'node:child_process'
110
+ import { promisify } from 'node:util'
111
+ import { resolveWorkerSecrets, withWorkerSecretsFile } from '@harlan-zw/nuxt-cloudflare/deploy'
112
+
113
+ const exec = promisify(execFile)
114
+
115
+ const resolved = resolveWorkerSecrets(['API_TOKEN'], process.env)
116
+ if (resolved._tag === 'missing')
117
+ throw new Error(`Missing Worker secrets: ${resolved.names.join(', ')}`)
118
+
119
+ await withWorkerSecretsFile({
120
+ path: '/secure/temp/secrets.json',
121
+ secrets: resolved.secrets,
122
+ use: path => exec('pnpm', ['wrangler', 'deploy', '--secrets-file', path]),
123
+ })
124
+ ```
125
+
126
+ The writer uses exclusive creation and mode 0600. It removes partial files after write failures and removes the completed file after deployment succeeds or fails.
127
+
128
+ ## Deliberate boundaries
129
+
130
+ The module does not choose Worker names, routes, domains, resource IDs, placement, CPU limits, queue jobs, R2 deletion policy, or deployment promotion. `@harlan-zw/nuxt-cf-jobs` continues to own queues, job durability, recovery, and outbox behavior.
131
+
132
+ Next high-value extractions from Nuxt SEO and gscdump:
133
+
134
+ 1. Nuxt Content D1 sync plus readiness verification
135
+ 2. Expand-only D1 migration audit with protected-table rebuild detection
136
+ 3. Lease/CAS API idempotency with canonical request fingerprints
137
+ 4. D1 request telemetry for serial waves, rows, regions, and primary versus replica reads
138
+ 5. Atomic D1 fixed-window rate limiting
139
+ 6. R2 lifecycle declaration and read-only storage stocktake
140
+
141
+ These remain separate adapters because their schemas, retention, and deployment ordering require explicit application policy.
@@ -0,0 +1,12 @@
1
+ interface CloudflareEventLike<Environment extends object> {
2
+ context?: {
3
+ cloudflare?: {
4
+ env?: Environment;
5
+ };
6
+ };
7
+ }
8
+ declare function getCloudflareBinding<Environment extends object, Name extends Extract<keyof Environment, string>>(event: CloudflareEventLike<Environment>, name: Name): Environment[Name] | undefined;
9
+ declare function requireCloudflareBinding<Environment extends object, Name extends Extract<keyof Environment, string>>(event: CloudflareEventLike<Environment>, name: Name): Exclude<Environment[Name], undefined>;
10
+
11
+ export { getCloudflareBinding, requireCloudflareBinding };
12
+ export type { CloudflareEventLike };
@@ -0,0 +1,12 @@
1
+ function getCloudflareBinding(event, name) {
2
+ const env = event.context?.cloudflare?.env;
3
+ return env && Object.hasOwn(env, name) ? env[name] : void 0;
4
+ }
5
+ function requireCloudflareBinding(event, name) {
6
+ const binding = getCloudflareBinding(event, name);
7
+ if (binding === void 0)
8
+ throw new Error(`Cloudflare binding "${name}" is unavailable`);
9
+ return binding;
10
+ }
11
+
12
+ export { getCloudflareBinding, requireCloudflareBinding };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ import process from 'node:process';
3
+ import { defineCommand, runMain } from 'citty';
4
+ import { resolve, dirname } from 'pathe';
5
+ import { diagnoseWranglerConfig, formatWranglerDiagnostics } from '../wrangler.mjs';
6
+ import { existsSync, readFileSync } from 'node:fs';
7
+ import { unstable_readConfig } from 'wrangler';
8
+ import 'node:fs/promises';
9
+
10
+ function resolveNitroDeployConfig(cwd) {
11
+ const redirectPath = resolve(cwd, ".wrangler/deploy/config.json");
12
+ if (!existsSync(redirectPath))
13
+ return void 0;
14
+ const parsed = JSON.parse(readFileSync(redirectPath, "utf8"));
15
+ if (!parsed || typeof parsed !== "object" || !("configPath" in parsed) || typeof parsed.configPath !== "string")
16
+ throw new Error(`Invalid Nitro deploy config: ${redirectPath}`);
17
+ return resolve(dirname(redirectPath), parsed.configPath);
18
+ }
19
+ function readProjectWranglerConfig(options) {
20
+ const configPath = options.config ? resolve(options.cwd, options.config) : resolveNitroDeployConfig(options.cwd);
21
+ const config = unstable_readConfig({
22
+ config: configPath,
23
+ env: options.environment,
24
+ script: resolve(options.cwd, "__nuxt-cloudflare-doctor.mjs")
25
+ }, {
26
+ hideWarnings: true,
27
+ useRedirectIfAvailable: false
28
+ });
29
+ return {
30
+ config,
31
+ path: config.configPath
32
+ };
33
+ }
34
+
35
+ const doctor = defineCommand({
36
+ meta: { name: "doctor", description: "Audit the effective Wrangler configuration" },
37
+ args: {
38
+ "cwd": { type: "string", description: "Project directory", default: "." },
39
+ "config": { type: "string", description: "Wrangler config path" },
40
+ "env": { type: "string", description: "Wrangler environment" },
41
+ "json": { type: "boolean", description: "Print JSON diagnostics", default: false },
42
+ "max-compatibility-age": { type: "string", description: "Compatibility date policy in days", default: "90" }
43
+ },
44
+ run({ args }) {
45
+ const cwd = resolve(args.cwd);
46
+ const loaded = readProjectWranglerConfig({ cwd, config: args.config, environment: args.env });
47
+ const diagnostics = diagnoseWranglerConfig(loaded.config, {
48
+ compatibilityMaxAgeDays: Number(args["max-compatibility-age"])
49
+ });
50
+ const payload = { configPath: loaded.path, diagnostics };
51
+ if (args.json)
52
+ process.stdout.write(`${JSON.stringify(payload, null, 2)}
53
+ `);
54
+ else if (diagnostics.length === 0)
55
+ process.stdout.write(`Cloudflare config valid: ${loaded.path ?? "inline/default"}
56
+ `);
57
+ else
58
+ process.stdout.write(`${formatWranglerDiagnostics(diagnostics)}
59
+ `);
60
+ if (diagnostics.some((diagnostic) => diagnostic._tag === "error"))
61
+ process.exitCode = 1;
62
+ }
63
+ });
64
+ const main = defineCommand({
65
+ meta: {
66
+ name: "nuxt-cloudflare",
67
+ version: "0.0.1",
68
+ description: "Cloudflare deployment defaults and diagnostics for Nuxt"
69
+ },
70
+ subCommands: { doctor }
71
+ });
72
+ runMain(main);
package/dist/d1.d.mts ADDED
@@ -0,0 +1,37 @@
1
+ type D1WriteSafety = {
2
+ _tag: 'lock-only';
3
+ } | {
4
+ _tag: 'replay-safe';
5
+ };
6
+ type D1Consistency = {
7
+ _tag: 'first-primary';
8
+ } | {
9
+ _tag: 'first-unconstrained';
10
+ } | {
11
+ _tag: 'bookmark';
12
+ bookmark: string;
13
+ };
14
+ interface D1SessionSource<Session> {
15
+ withSession: (constraint: string) => Session;
16
+ }
17
+ interface RetryIdempotentD1WriteOptions<T> {
18
+ maxAttempts?: number;
19
+ random?: () => number;
20
+ run: () => Promise<T>;
21
+ safety: D1WriteSafety;
22
+ sleep?: (milliseconds: number) => Promise<void>;
23
+ }
24
+ type D1RetryErrorKind = {
25
+ _tag: 'lock';
26
+ } | {
27
+ _tag: 'transient';
28
+ } | {
29
+ _tag: 'permanent';
30
+ };
31
+ declare function classifyD1RetryError(error: unknown): D1RetryErrorKind;
32
+ declare function isTransientD1Error(error: unknown): boolean;
33
+ declare function getRequestD1Session<Session>(requestContext: Record<PropertyKey, unknown>, binding: string, database: D1SessionSource<Session>, consistency?: D1Consistency): Session;
34
+ declare function retryIdempotentD1Write<T>(options: RetryIdempotentD1WriteOptions<T>): Promise<T>;
35
+
36
+ export { classifyD1RetryError, getRequestD1Session, isTransientD1Error, retryIdempotentD1Write };
37
+ export type { D1Consistency, D1RetryErrorKind, D1SessionSource, D1WriteSafety, RetryIdempotentD1WriteOptions };
package/dist/d1.mjs ADDED
@@ -0,0 +1,76 @@
1
+ const REQUEST_D1_SESSIONS = Symbol.for("@harlan-zw/nuxt-cloudflare:d1-sessions");
2
+ const TRANSIENT_D1_SIGNALS = [
3
+ "Network connection lost",
4
+ "operation was aborted",
5
+ "overloaded",
6
+ "Requests queued for too long",
7
+ "exceeded its CPU time limit",
8
+ "storage caused object to be reset",
9
+ "reset because its code was updated",
10
+ "Internal error in D1",
11
+ "cannot resolve d1 db due to transient issue on remote node"
12
+ ];
13
+ function consistencyConstraint(consistency) {
14
+ if (consistency._tag === "bookmark")
15
+ return consistency.bookmark;
16
+ return consistency._tag;
17
+ }
18
+ function retryDelay(attempt, random) {
19
+ const exponentialDelay = 60 * 2 ** attempt;
20
+ return Math.round(exponentialDelay * (0.5 + random()));
21
+ }
22
+ function defaultSleep(milliseconds) {
23
+ return new Promise((resolve) => setTimeout(resolve, milliseconds));
24
+ }
25
+ function parseMaxAttempts(value) {
26
+ const attempts = value ?? 4;
27
+ if (!Number.isSafeInteger(attempts) || attempts < 1)
28
+ throw new TypeError("D1 maxAttempts must be a positive integer");
29
+ return attempts;
30
+ }
31
+ function classifyD1RetryError(error) {
32
+ const message = error instanceof Error ? error.message : String(error);
33
+ if (/busy|locked/i.test(message))
34
+ return { _tag: "lock" };
35
+ if (TRANSIENT_D1_SIGNALS.some((signal) => message.includes(signal)))
36
+ return { _tag: "transient" };
37
+ return { _tag: "permanent" };
38
+ }
39
+ function isTransientD1Error(error) {
40
+ return classifyD1RetryError(error)._tag === "transient";
41
+ }
42
+ function getRequestD1Session(requestContext, binding, database, consistency = { _tag: "first-primary" }) {
43
+ const existing = requestContext[REQUEST_D1_SESSIONS];
44
+ if (existing !== void 0 && !(existing instanceof Map))
45
+ throw new TypeError("Request D1 session cache has an invalid value");
46
+ const sessions = existing ?? /* @__PURE__ */ new Map();
47
+ requestContext[REQUEST_D1_SESSIONS] = sessions;
48
+ const constraint = consistencyConstraint(consistency);
49
+ const key = `${binding}:${constraint}`;
50
+ if (!sessions.has(key))
51
+ sessions.set(key, database.withSession(constraint));
52
+ return sessions.get(key);
53
+ }
54
+ async function retryIdempotentD1Write(options) {
55
+ const maxAttempts = parseMaxAttempts(options.maxAttempts);
56
+ const random = options.random ?? Math.random;
57
+ const sleep = options.sleep ?? defaultSleep;
58
+ let lastError;
59
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
60
+ const outcome = await options.run().then(
61
+ (value) => ({ _tag: "ok", value }),
62
+ (error) => ({ _tag: "error", error })
63
+ );
64
+ if (outcome._tag === "ok")
65
+ return outcome.value;
66
+ lastError = outcome.error;
67
+ const kind = classifyD1RetryError(outcome.error);
68
+ const retryable = kind._tag === "lock" || kind._tag === "transient" && options.safety._tag === "replay-safe";
69
+ if (!retryable || attempt + 1 >= maxAttempts)
70
+ throw outcome.error;
71
+ await sleep(retryDelay(attempt, random));
72
+ }
73
+ throw lastError;
74
+ }
75
+
76
+ export { classifyD1RetryError, getRequestD1Session, isTransientD1Error, retryIdempotentD1Write };
@@ -0,0 +1,17 @@
1
+ type WorkerSecretsResolution = {
2
+ _tag: 'missing';
3
+ names: string[];
4
+ } | {
5
+ _tag: 'resolved';
6
+ secrets: Record<string, string>;
7
+ };
8
+ interface WorkerSecretsFileOptions<T> {
9
+ path: string;
10
+ secrets: Readonly<Record<string, string>>;
11
+ use: (path: string) => Promise<T> | T;
12
+ }
13
+ declare function resolveWorkerSecrets(requiredNames: readonly string[], environment: Readonly<Record<string, string | undefined>>): WorkerSecretsResolution;
14
+ declare function withWorkerSecretsFile<T>(options: WorkerSecretsFileOptions<T>): Promise<T>;
15
+
16
+ export { resolveWorkerSecrets, withWorkerSecretsFile };
17
+ export type { WorkerSecretsFileOptions, WorkerSecretsResolution };
@@ -0,0 +1,58 @@
1
+ import { open, unlink } from 'node:fs/promises';
2
+
3
+ function resolveWorkerSecrets(requiredNames, environment) {
4
+ const names = [...new Set(requiredNames)];
5
+ const missing = names.filter((name) => environment[name] === void 0 || environment[name] === "");
6
+ if (missing.length > 0)
7
+ return { _tag: "missing", names: missing };
8
+ return {
9
+ _tag: "resolved",
10
+ secrets: Object.fromEntries(names.map((name) => [name, environment[name]]))
11
+ };
12
+ }
13
+ function settle(promise) {
14
+ return promise.then(
15
+ (value) => ({ _tag: "ok", value }),
16
+ (error) => ({ _tag: "error", error })
17
+ );
18
+ }
19
+ function isMissingFileError(error) {
20
+ return error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT";
21
+ }
22
+ function throwFailures(errors, message) {
23
+ if (errors.length === 1)
24
+ throw errors[0];
25
+ throw new AggregateError(errors, message);
26
+ }
27
+ async function removeWorkerSecretsFile(path) {
28
+ const outcome = await settle(unlink(path));
29
+ if (outcome._tag === "error" && !isMissingFileError(outcome.error))
30
+ throw outcome.error;
31
+ }
32
+ async function writeWorkerSecretsFile(path, secrets) {
33
+ const payload = `${JSON.stringify(secrets)}
34
+ `;
35
+ const handle = await open(path, "wx", 384);
36
+ const writeOutcome = await settle(handle.writeFile(payload, "utf8"));
37
+ const closeOutcome = await settle(handle.close());
38
+ const failures = [writeOutcome, closeOutcome].filter((outcome) => outcome._tag === "error").map((outcome) => outcome.error);
39
+ if (failures.length === 0)
40
+ return;
41
+ const cleanupOutcome = await settle(removeWorkerSecretsFile(path));
42
+ if (cleanupOutcome._tag === "error")
43
+ failures.push(cleanupOutcome.error);
44
+ throwFailures(failures, "Failed to write and clean up the Worker secrets file");
45
+ }
46
+ async function withWorkerSecretsFile(options) {
47
+ await writeWorkerSecretsFile(options.path, options.secrets);
48
+ const useOutcome = await settle(Promise.resolve().then(() => options.use(options.path)));
49
+ const cleanupOutcome = await settle(removeWorkerSecretsFile(options.path));
50
+ const failures = [useOutcome, cleanupOutcome].filter((outcome) => outcome._tag === "error").map((outcome) => outcome.error);
51
+ if (failures.length > 0)
52
+ throwFailures(failures, "Worker deployment and secrets file cleanup failed");
53
+ if (useOutcome._tag === "error")
54
+ throw useOutcome.error;
55
+ return useOutcome.value;
56
+ }
57
+
58
+ export { resolveWorkerSecrets, withWorkerSecretsFile };
@@ -0,0 +1,37 @@
1
+ import { WranglerConfigInput } from './wrangler.mjs';
2
+ import { Nuxt } from '@nuxt/schema';
3
+
4
+ interface ModuleOptions {
5
+ enabled?: boolean;
6
+ compatibilityDate?: string;
7
+ compatibilityMaxAgeDays?: number;
8
+ kvCache?: false | {
9
+ binding: string;
10
+ defaultTtl?: number;
11
+ };
12
+ logsSampleRate?: number;
13
+ publicVarNames?: string[];
14
+ requiredSecrets?: string[];
15
+ sourceMaps?: boolean;
16
+ tracesSampleRate?: number;
17
+ versionMetadataBinding?: string;
18
+ }
19
+ interface NitroStorageMount extends Record<string, unknown> {
20
+ driver?: unknown;
21
+ }
22
+ interface NitroCloudflareShape {
23
+ cloudflare?: {
24
+ deployConfig?: boolean;
25
+ nodeCompat?: boolean;
26
+ wrangler?: WranglerConfigInput;
27
+ };
28
+ preset?: string;
29
+ sourceMap?: boolean;
30
+ storage?: Record<string, NitroStorageMount>;
31
+ }
32
+ declare function configureNitroCloudflare(nitro: NitroCloudflareShape, options: ModuleOptions, nuxtServerSourceMaps?: boolean): void;
33
+ declare function setupCloudflareModule(options: ModuleOptions, nuxt: Nuxt): void;
34
+ declare const _default: any;
35
+
36
+ export { configureNitroCloudflare, _default as default, setupCloudflareModule };
37
+ export type { ModuleOptions, NitroCloudflareShape };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@harlan-zw/nuxt-cloudflare",
3
+ "configKey": "nuxtCloudflare",
4
+ "compatibility": {
5
+ "nuxt": ">=4.5.0"
6
+ },
7
+ "version": "0.0.1",
8
+ "builder": {
9
+ "@nuxt/module-builder": "1.0.3",
10
+ "unbuild": "3.6.1"
11
+ }
12
+ }
@@ -0,0 +1,88 @@
1
+ import { useLogger, defineNuxtModule } from '@nuxt/kit';
2
+ import { resolve } from 'pathe';
3
+ import { readWranglerJsonFile, diagnoseWranglerConfig, formatWranglerDiagnostics, applyCloudflareDefaults } from './wrangler.mjs';
4
+ import 'node:fs/promises';
5
+
6
+ const logger = useLogger("nuxt-cloudflare");
7
+ const cacheDriverPath = resolve(import.meta.dirname, import.meta.url.endsWith(".ts") ? "storage.ts" : "storage.mjs");
8
+ function configureNitroCloudflare(nitro, options, nuxtServerSourceMaps) {
9
+ nitro.preset ??= "cloudflare-module";
10
+ nitro.cloudflare ??= {};
11
+ nitro.cloudflare.deployConfig = true;
12
+ nitro.cloudflare.nodeCompat = true;
13
+ nitro.cloudflare.wrangler = applyCloudflareDefaults(nitro.cloudflare.wrangler ?? {}, {
14
+ compatibilityDate: options.compatibilityDate,
15
+ logsSampleRate: options.logsSampleRate,
16
+ requiredSecrets: options.requiredSecrets,
17
+ tracesSampleRate: options.tracesSampleRate,
18
+ uploadSourceMaps: options.sourceMaps ?? nitro.sourceMap ?? nuxtServerSourceMaps ?? false,
19
+ versionMetadataBinding: options.versionMetadataBinding
20
+ });
21
+ if (options.kvCache === false)
22
+ return;
23
+ const cache = nitro.storage?.cache;
24
+ const configuredCache = options.kvCache;
25
+ if (!configuredCache && cache?.driver !== "cloudflare-kv-binding")
26
+ return;
27
+ nitro.storage ??= {};
28
+ nitro.storage.cache = {
29
+ ...cache ?? {},
30
+ ...configuredCache ? { binding: configuredCache.binding } : {},
31
+ driver: cacheDriverPath,
32
+ defaultTtl: configuredCache?.defaultTtl ?? 30 * 24 * 60 * 60
33
+ };
34
+ }
35
+ async function auditGeneratedWranglerConfig(nitro, options) {
36
+ const path = resolve(nitro.options.output.serverDir, "wrangler.json");
37
+ const result = await readWranglerJsonFile(path);
38
+ if (result._tag === "missing")
39
+ throw new Error(`[nuxt-cloudflare] Generated Wrangler config is missing: ${path}`);
40
+ if (result._tag === "invalid")
41
+ throw new Error(`[nuxt-cloudflare] Generated Wrangler config is invalid: ${result.reason}`);
42
+ const diagnostics = diagnoseWranglerConfig(result.config, {
43
+ compatibilityMaxAgeDays: options.compatibilityMaxAgeDays,
44
+ publicVarNames: options.publicVarNames
45
+ });
46
+ const warnings = diagnostics.filter((diagnostic) => diagnostic._tag === "warning");
47
+ const errors = diagnostics.filter((diagnostic) => diagnostic._tag === "error");
48
+ if (warnings.length > 0)
49
+ logger.warn(formatWranglerDiagnostics(warnings));
50
+ if (errors.length > 0)
51
+ throw new Error(`[nuxt-cloudflare]
52
+ ${formatWranglerDiagnostics(errors)}`);
53
+ }
54
+ function setupCloudflareModule(options, nuxt) {
55
+ if (!options.enabled)
56
+ return;
57
+ const configure = () => configureNitroCloudflare(
58
+ nuxt.options.nitro,
59
+ options,
60
+ Boolean(nuxt.options.sourcemap.server)
61
+ );
62
+ configure();
63
+ nuxt.hook("modules:done", () => {
64
+ configure();
65
+ });
66
+ if (!nuxt.options.dev) {
67
+ nuxt.hook("nitro:init", (nitro) => {
68
+ nitro.hooks.hook("compiled", () => auditGeneratedWranglerConfig(nitro, options));
69
+ });
70
+ }
71
+ }
72
+ const module$1 = defineNuxtModule({
73
+ meta: {
74
+ name: "@harlan-zw/nuxt-cloudflare",
75
+ configKey: "nuxtCloudflare",
76
+ compatibility: { nuxt: ">=4.5.0" }
77
+ },
78
+ defaults: {
79
+ enabled: true,
80
+ compatibilityMaxAgeDays: 90,
81
+ logsSampleRate: 0.1,
82
+ tracesSampleRate: 0.01,
83
+ versionMetadataBinding: "CF_VERSION_METADATA"
84
+ },
85
+ setup: setupCloudflareModule
86
+ });
87
+
88
+ export { configureNitroCloudflare, module$1 as default, setupCloudflareModule };
@@ -0,0 +1,12 @@
1
+ import { Driver } from 'unstorage';
2
+ import { KVOptions } from 'unstorage/drivers/cloudflare-kv-binding';
3
+
4
+ interface CloudflareKvCacheOptions extends KVOptions {
5
+ /** Physical expiry for writes whose caller omitted a TTL, in seconds. */
6
+ defaultTtl: number;
7
+ }
8
+ declare function withDefaultKvExpiration<Options, Instance>(driver: Driver<Options, Instance>, defaultTtl: number): Driver<Options, Instance>;
9
+ declare const cloudflareKvCacheDriver: any;
10
+
11
+ export { cloudflareKvCacheDriver as default, withDefaultKvExpiration };
12
+ export type { CloudflareKvCacheOptions };
@@ -0,0 +1,33 @@
1
+ import { defineDriver } from 'unstorage';
2
+ import cloudflareKvBindingDriver from 'unstorage/drivers/cloudflare-kv-binding';
3
+
4
+ function parseDefaultTtl(defaultTtl) {
5
+ if (!Number.isSafeInteger(defaultTtl) || defaultTtl < 60)
6
+ throw new Error("Cloudflare KV cache defaultTtl must be an integer of at least 60 seconds");
7
+ return defaultTtl;
8
+ }
9
+ function withDefaultKvExpiration(driver, defaultTtl) {
10
+ const parsedDefaultTtl = parseDefaultTtl(defaultTtl);
11
+ const setItem = driver.setItem;
12
+ if (!setItem)
13
+ throw new Error("Cloudflare KV cache driver must implement setItem");
14
+ return {
15
+ ...driver,
16
+ name: "cloudflare-kv-binding-expiring-cache",
17
+ flags: { ...driver.flags, ttl: true },
18
+ setItem(key, value, transactionOptions = {}) {
19
+ const requestedTtl = Number(transactionOptions.ttl);
20
+ const ttl = Number.isFinite(requestedTtl) && requestedTtl > 0 ? requestedTtl : parsedDefaultTtl;
21
+ return setItem(key, value, { ...transactionOptions, ttl });
22
+ }
23
+ };
24
+ }
25
+ const cloudflareKvCacheDriver = defineDriver((options) => {
26
+ const driver = {
27
+ ...cloudflareKvBindingDriver(options),
28
+ options
29
+ };
30
+ return withDefaultKvExpiration(driver, options.defaultTtl);
31
+ });
32
+
33
+ export { cloudflareKvCacheDriver as default, withDefaultKvExpiration };
@@ -0,0 +1,3 @@
1
+ export { type configureNitroCloudflare, default, type setupCloudflareModule } from './module.mjs'
2
+
3
+ export { type ModuleOptions, type NitroCloudflareShape } from './module.mjs'
@@ -0,0 +1,75 @@
1
+ interface WranglerAssetsInput {
2
+ directory?: string;
3
+ binding?: string;
4
+ run_worker_first?: boolean | string[];
5
+ }
6
+ interface WranglerObservabilityInput {
7
+ enabled?: boolean;
8
+ head_sampling_rate?: number;
9
+ logs?: {
10
+ enabled?: boolean;
11
+ head_sampling_rate?: number;
12
+ invocation_logs?: boolean;
13
+ };
14
+ traces?: {
15
+ enabled?: boolean;
16
+ head_sampling_rate?: number;
17
+ };
18
+ }
19
+ interface WranglerConfigInput extends Record<string, unknown> {
20
+ assets?: WranglerAssetsInput;
21
+ compatibility_date?: string;
22
+ compatibility_flags?: string[];
23
+ env?: Record<string, WranglerConfigInput>;
24
+ observability?: WranglerObservabilityInput;
25
+ queues?: {
26
+ consumers?: Array<Record<string, unknown>>;
27
+ };
28
+ secrets?: {
29
+ required?: string[];
30
+ };
31
+ upload_source_maps?: boolean;
32
+ vars?: Record<string, unknown>;
33
+ version_metadata?: {
34
+ binding: string;
35
+ };
36
+ workers_dev?: boolean;
37
+ }
38
+ interface CloudflareDefaultOptions {
39
+ compatibilityDate?: string;
40
+ logsSampleRate?: number;
41
+ requiredSecrets?: readonly string[];
42
+ tracesSampleRate?: number;
43
+ uploadSourceMaps?: boolean;
44
+ versionMetadataBinding?: string;
45
+ }
46
+ interface WranglerDiagnostic {
47
+ _tag: 'error' | 'warning';
48
+ code: 'assets-worker-first' | 'compatibility-date-missing' | 'compatibility-date-invalid' | 'missing-nodejs-compat' | 'observability-disabled' | 'plaintext-secret-var' | 'queue-retries-excessive' | 'secret-declared-as-var' | 'source-maps-disabled' | 'stale-compatibility-date' | 'version-metadata-missing' | 'workers-dev-enabled';
49
+ message: string;
50
+ path: string;
51
+ }
52
+ interface WranglerDiagnosticOptions {
53
+ compatibilityMaxAgeDays?: number;
54
+ now?: Date;
55
+ publicVarNames?: readonly string[];
56
+ }
57
+ type WranglerJsonFileResult = {
58
+ _tag: 'loaded';
59
+ config: WranglerConfigInput;
60
+ path: string;
61
+ } | {
62
+ _tag: 'missing';
63
+ path: string;
64
+ } | {
65
+ _tag: 'invalid';
66
+ path: string;
67
+ reason: string;
68
+ };
69
+ declare function applyCloudflareDefaults(config: WranglerConfigInput, options?: CloudflareDefaultOptions): WranglerConfigInput;
70
+ declare function diagnoseWranglerConfig(config: WranglerConfigInput, options?: WranglerDiagnosticOptions): WranglerDiagnostic[];
71
+ declare function formatWranglerDiagnostics(diagnostics: readonly WranglerDiagnostic[]): string;
72
+ declare function readWranglerJsonFile(path: string): Promise<WranglerJsonFileResult>;
73
+
74
+ export { applyCloudflareDefaults, diagnoseWranglerConfig, formatWranglerDiagnostics, readWranglerJsonFile };
75
+ export type { CloudflareDefaultOptions, WranglerAssetsInput, WranglerConfigInput, WranglerDiagnostic, WranglerDiagnosticOptions, WranglerJsonFileResult, WranglerObservabilityInput };
@@ -0,0 +1,244 @@
1
+ import { readFile } from 'node:fs/promises';
2
+
3
+ const SECRET_NAME_RE = /(?:^|_)(?:API_?KEY|AUTH_TOKEN|CLIENT_SECRET|CREDENTIALS?|DATABASE_URL|DB_URL|ENCRYPTION_KEY|KEY|PASSWORD|PRIVATE_KEY|SECRET|SIGNING_KEY|TOKEN)(?:_|$)/i;
4
+ const DATE_ONLY_RE = /^\d{4}-\d{2}-\d{2}$/;
5
+ const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1e3;
6
+ function unique(values) {
7
+ return [...new Set(values)];
8
+ }
9
+ function isRecord(value) {
10
+ return value !== null && typeof value === "object" && !Array.isArray(value);
11
+ }
12
+ function parseDateOnly(value) {
13
+ if (!DATE_ONLY_RE.test(value))
14
+ return void 0;
15
+ const date = /* @__PURE__ */ new Date(`${value}T00:00:00.000Z`);
16
+ return Number.isNaN(date.getTime()) || date.toISOString().slice(0, 10) !== value ? void 0 : date;
17
+ }
18
+ function hasOwn(value, key) {
19
+ return Object.hasOwn(value, key);
20
+ }
21
+ function applyCloudflareDefaults(config, options = {}) {
22
+ const root = applyEnvironmentDefaults(config, options);
23
+ const environments = config.env && Object.fromEntries(
24
+ Object.entries(config.env).map(([name, environment]) => [name, applyEnvironmentDefaults(environment, {
25
+ ...options,
26
+ requiredSecrets: root.secrets?.required
27
+ }, root)])
28
+ );
29
+ return environments ? { ...root, env: environments } : root;
30
+ }
31
+ function applyEnvironmentDefaults(config, options, inherited = {}) {
32
+ const compatibilityDate = config.compatibility_date ?? inherited.compatibility_date ?? options.compatibilityDate;
33
+ const compatibilityFlags = unique([...config.compatibility_flags ?? inherited.compatibility_flags ?? [], "nodejs_compat"]);
34
+ const requiredSecrets = unique([...config.secrets?.required ?? [], ...options.requiredSecrets ?? []]);
35
+ const logs = config.observability?.logs;
36
+ const inheritedLogs = inherited.observability?.logs;
37
+ const traces = config.observability?.traces;
38
+ const inheritedTraces = inherited.observability?.traces;
39
+ const uploadSourceMaps = config.upload_source_maps ?? inherited.upload_source_maps ?? options.uploadSourceMaps ?? true;
40
+ return {
41
+ ...config,
42
+ ...compatibilityDate === void 0 ? {} : { compatibility_date: compatibilityDate },
43
+ compatibility_flags: compatibilityFlags,
44
+ observability: {
45
+ ...inherited.observability,
46
+ ...config.observability,
47
+ enabled: config.observability?.enabled ?? inherited.observability?.enabled ?? true,
48
+ logs: {
49
+ ...inheritedLogs,
50
+ ...logs,
51
+ enabled: logs?.enabled ?? inheritedLogs?.enabled ?? true,
52
+ head_sampling_rate: logs?.head_sampling_rate ?? inheritedLogs?.head_sampling_rate ?? options.logsSampleRate ?? 0.1,
53
+ invocation_logs: logs?.invocation_logs ?? inheritedLogs?.invocation_logs ?? true
54
+ },
55
+ traces: {
56
+ ...inheritedTraces,
57
+ ...traces,
58
+ enabled: traces?.enabled ?? inheritedTraces?.enabled ?? true,
59
+ head_sampling_rate: traces?.head_sampling_rate ?? inheritedTraces?.head_sampling_rate ?? options.tracesSampleRate ?? 0.01
60
+ }
61
+ },
62
+ ...requiredSecrets.length > 0 ? { secrets: { ...config.secrets, required: requiredSecrets } } : {},
63
+ upload_source_maps: uploadSourceMaps,
64
+ version_metadata: config.version_metadata ?? inherited.version_metadata ?? {
65
+ binding: options.versionMetadataBinding ?? "CF_VERSION_METADATA"
66
+ }
67
+ };
68
+ }
69
+ function diagnoseEnvironment(config, prefix, diagnostics, publicVarNames) {
70
+ if (config.assets && hasOwn(config.assets, "run_worker_first")) {
71
+ diagnostics.push({
72
+ _tag: "error",
73
+ code: "assets-worker-first",
74
+ message: "Remove assets.run_worker_first. Static assets must bypass the Worker.",
75
+ path: `${prefix}assets.run_worker_first`
76
+ });
77
+ }
78
+ const requiredSecrets = new Set(config.secrets?.required ?? []);
79
+ for (const name of Object.keys(config.vars ?? {})) {
80
+ const path = `${prefix}vars.${name}`;
81
+ if (requiredSecrets.has(name)) {
82
+ diagnostics.push({
83
+ _tag: "error",
84
+ code: "secret-declared-as-var",
85
+ message: `Remove ${name} from vars; it is declared as a required encrypted secret.`,
86
+ path
87
+ });
88
+ continue;
89
+ }
90
+ if (!publicVarNames.has(name) && !/^(?:NUXT_)?PUBLIC_/i.test(name) && SECRET_NAME_RE.test(name)) {
91
+ diagnostics.push({
92
+ _tag: "error",
93
+ code: "plaintext-secret-var",
94
+ message: `Move secret-looking variable ${name} to an encrypted Worker secret.`,
95
+ path
96
+ });
97
+ }
98
+ }
99
+ const consumers = config.queues?.consumers ?? [];
100
+ consumers.forEach((consumer, index) => {
101
+ const retries = consumer.max_retries;
102
+ if (typeof retries === "number" && retries > 10) {
103
+ diagnostics.push({
104
+ _tag: "warning",
105
+ code: "queue-retries-excessive",
106
+ message: `Queue consumer retries ${retries} times; verify this is intentional and backed by a DLQ.`,
107
+ path: `${prefix}queues.consumers.${index}.max_retries`
108
+ });
109
+ }
110
+ });
111
+ }
112
+ function diagnosePolicy(config, prefix, diagnostics, options, publicVarNames) {
113
+ const compatibilityDate = config.compatibility_date;
114
+ if (compatibilityDate === void 0) {
115
+ diagnostics.push({
116
+ _tag: "error",
117
+ code: "compatibility-date-missing",
118
+ message: "Set an explicit compatibility_date.",
119
+ path: `${prefix}compatibility_date`
120
+ });
121
+ } else {
122
+ const parsed = parseDateOnly(compatibilityDate);
123
+ if (!parsed) {
124
+ diagnostics.push({
125
+ _tag: "error",
126
+ code: "compatibility-date-invalid",
127
+ message: "compatibility_date must be a real YYYY-MM-DD date.",
128
+ path: `${prefix}compatibility_date`
129
+ });
130
+ } else if ((options.now.getTime() - parsed.getTime()) / MILLISECONDS_PER_DAY > options.compatibilityMaxAgeDays) {
131
+ diagnostics.push({
132
+ _tag: "warning",
133
+ code: "stale-compatibility-date",
134
+ message: `compatibility_date is older than the ${options.compatibilityMaxAgeDays}-day project policy. Review compatibility flags before advancing it.`,
135
+ path: `${prefix}compatibility_date`
136
+ });
137
+ }
138
+ }
139
+ if (!config.compatibility_flags?.includes("nodejs_compat")) {
140
+ diagnostics.push({
141
+ _tag: "error",
142
+ code: "missing-nodejs-compat",
143
+ message: "Add nodejs_compat to compatibility_flags.",
144
+ path: `${prefix}compatibility_flags`
145
+ });
146
+ }
147
+ if (config.observability?.enabled !== true) {
148
+ diagnostics.push({
149
+ _tag: "warning",
150
+ code: "observability-disabled",
151
+ message: "Enable Workers observability.",
152
+ path: `${prefix}observability.enabled`
153
+ });
154
+ }
155
+ if (config.upload_source_maps !== true) {
156
+ diagnostics.push({
157
+ _tag: "warning",
158
+ code: "source-maps-disabled",
159
+ message: "Enable upload_source_maps when the Worker build emits source maps.",
160
+ path: `${prefix}upload_source_maps`
161
+ });
162
+ }
163
+ if (!config.version_metadata?.binding) {
164
+ diagnostics.push({
165
+ _tag: "warning",
166
+ code: "version-metadata-missing",
167
+ message: "Add a version_metadata binding for deployment correlation.",
168
+ path: `${prefix}version_metadata`
169
+ });
170
+ }
171
+ if (config.workers_dev === true) {
172
+ diagnostics.push({
173
+ _tag: "warning",
174
+ code: "workers-dev-enabled",
175
+ message: "Production workers.dev exposure is enabled; verify this is intentional.",
176
+ path: `${prefix}workers_dev`
177
+ });
178
+ }
179
+ diagnoseEnvironment(config, prefix, diagnostics, publicVarNames);
180
+ }
181
+ function mergeObservability(inherited, environment) {
182
+ if (!inherited && !environment)
183
+ return void 0;
184
+ return {
185
+ ...inherited,
186
+ ...environment,
187
+ logs: inherited?.logs || environment?.logs ? { ...inherited?.logs, ...environment?.logs } : void 0,
188
+ traces: inherited?.traces || environment?.traces ? { ...inherited?.traces, ...environment?.traces } : void 0
189
+ };
190
+ }
191
+ function resolveEnvironmentPolicy(root, environment) {
192
+ return {
193
+ ...environment,
194
+ compatibility_date: environment.compatibility_date ?? root.compatibility_date,
195
+ compatibility_flags: environment.compatibility_flags ?? root.compatibility_flags,
196
+ observability: mergeObservability(root.observability, environment.observability),
197
+ upload_source_maps: environment.upload_source_maps ?? root.upload_source_maps,
198
+ workers_dev: environment.workers_dev ?? root.workers_dev
199
+ };
200
+ }
201
+ function diagnoseWranglerConfig(config, options = {}) {
202
+ const diagnostics = [];
203
+ const diagnosticOptions = {
204
+ compatibilityMaxAgeDays: options.compatibilityMaxAgeDays ?? 90,
205
+ now: options.now ?? /* @__PURE__ */ new Date()
206
+ };
207
+ const publicVarNames = new Set(options.publicVarNames ?? []);
208
+ diagnosePolicy(config, "", diagnostics, diagnosticOptions, publicVarNames);
209
+ for (const [name, environment] of Object.entries(config.env ?? {})) {
210
+ diagnosePolicy(
211
+ resolveEnvironmentPolicy(config, environment),
212
+ `env.${name}.`,
213
+ diagnostics,
214
+ diagnosticOptions,
215
+ publicVarNames
216
+ );
217
+ }
218
+ return diagnostics;
219
+ }
220
+ function formatWranglerDiagnostics(diagnostics) {
221
+ return diagnostics.map((diagnostic) => `${diagnostic._tag === "error" ? "ERROR" : "WARN"} ${diagnostic.code} ${diagnostic.path}: ${diagnostic.message}`).join("\n");
222
+ }
223
+ async function readWranglerJsonFile(path) {
224
+ return readFile(path, "utf8").then((source) => {
225
+ const parsed = (() => {
226
+ try {
227
+ return { _tag: "parsed", value: JSON.parse(source) };
228
+ } catch (error) {
229
+ return { _tag: "invalid", reason: error instanceof Error ? error.message : String(error) };
230
+ }
231
+ })();
232
+ if (parsed._tag === "invalid")
233
+ return { _tag: "invalid", path, reason: parsed.reason };
234
+ if (!isRecord(parsed.value))
235
+ return { _tag: "invalid", path, reason: "top-level value must be an object" };
236
+ return { _tag: "loaded", path, config: parsed.value };
237
+ }).catch((error) => {
238
+ if (isRecord(error) && error.code === "ENOENT")
239
+ return { _tag: "missing", path };
240
+ throw error;
241
+ });
242
+ }
243
+
244
+ export { applyCloudflareDefaults, diagnoseWranglerConfig, formatWranglerDiagnostics, readWranglerJsonFile };
package/package.json ADDED
@@ -0,0 +1,118 @@
1
+ {
2
+ "name": "@harlan-zw/nuxt-cloudflare",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "description": "Opinionated Cloudflare deployment defaults and diagnostics for Nuxt.",
6
+ "author": {
7
+ "name": "Harlan Wilton",
8
+ "email": "harlan@harlanzw.com",
9
+ "url": "https://harlanzw.com/"
10
+ },
11
+ "license": "MIT",
12
+ "funding": "https://github.com/sponsors/harlan-zw",
13
+ "homepage": "https://github.com/harlan-zw/harlan-nuxt/tree/main/packages/nuxt-cloudflare#readme",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/harlan-zw/harlan-nuxt.git",
17
+ "directory": "packages/nuxt-cloudflare"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/harlan-zw/harlan-nuxt/issues"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "sideEffects": false,
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/module.d.mts",
29
+ "import": "./dist/module.mjs"
30
+ },
31
+ "./d1": {
32
+ "types": "./dist/d1.d.mts",
33
+ "import": "./dist/d1.mjs"
34
+ },
35
+ "./bindings": {
36
+ "types": "./dist/bindings.d.mts",
37
+ "import": "./dist/bindings.mjs"
38
+ },
39
+ "./deploy": {
40
+ "types": "./dist/deploy.d.mts",
41
+ "import": "./dist/deploy.mjs"
42
+ },
43
+ "./storage": {
44
+ "types": "./dist/storage.d.mts",
45
+ "import": "./dist/storage.mjs"
46
+ },
47
+ "./wrangler": {
48
+ "types": "./dist/wrangler.d.mts",
49
+ "import": "./dist/wrangler.mjs"
50
+ }
51
+ },
52
+ "main": "./dist/module.mjs",
53
+ "types": "./dist/module.d.mts",
54
+ "typesVersions": {
55
+ "*": {
56
+ "bindings": [
57
+ "dist/bindings.d.mts"
58
+ ],
59
+ "d1": [
60
+ "dist/d1.d.mts"
61
+ ],
62
+ "deploy": [
63
+ "dist/deploy.d.mts"
64
+ ],
65
+ "storage": [
66
+ "dist/storage.d.mts"
67
+ ],
68
+ "wrangler": [
69
+ "dist/wrangler.d.mts"
70
+ ]
71
+ }
72
+ },
73
+ "bin": {
74
+ "nuxt-cloudflare": "dist/cli/index.mjs"
75
+ },
76
+ "files": [
77
+ "dist"
78
+ ],
79
+ "engines": {
80
+ "node": ">=22.12.0"
81
+ },
82
+ "peerDependencies": {
83
+ "nuxt": ">=4.5.0 <5.0.0",
84
+ "wrangler": ">=4.120.0 <5.0.0"
85
+ },
86
+ "dependencies": {
87
+ "@nuxt/kit": "^4.5.2",
88
+ "citty": "^0.2.2",
89
+ "consola": "^3.4.2",
90
+ "pathe": "^2.0.3",
91
+ "unstorage": "^1.17.5"
92
+ },
93
+ "devDependencies": {
94
+ "@antfu/eslint-config": "^9.3.0",
95
+ "@arethetypeswrong/cli": "^0.18.5",
96
+ "@cloudflare/workers-types": "^5.20260809.1",
97
+ "@nuxt/module-builder": "^1.0.2",
98
+ "@nuxt/schema": "^4.5.2",
99
+ "@types/node": "^26.1.1",
100
+ "eslint": "^10.8.1",
101
+ "nuxt": "^4.5.2",
102
+ "typescript": "^5.9.3",
103
+ "unbuild": "^3.6.1",
104
+ "vitest": "^4.1.10",
105
+ "wrangler": "^4.120.0"
106
+ },
107
+ "scripts": {
108
+ "build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build",
109
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare",
110
+ "lint": "eslint .",
111
+ "lint:fix": "eslint . --fix",
112
+ "test": "pnpm run build && vitest run && pnpm run test:fixture",
113
+ "test:fixture": "nuxt build tests/fixtures/basic && node dist/cli/index.mjs doctor --cwd tests/fixtures/basic",
114
+ "typecheck": "nuxt typecheck && tsc --noEmit -p tsconfig.check.json",
115
+ "test:attw": "attw --pack",
116
+ "test:pack": "rm -rf .pack && pnpm pack --pack-destination .pack && tar -tf .pack/*.tgz"
117
+ }
118
+ }