@bino0216/nitro-cloudflare-dev 0.2.4 → 0.2.6

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/dist/index.d.mts CHANGED
@@ -25,9 +25,13 @@ interface CloudflareDevOptions {
25
25
  environment?: string;
26
26
  persistDir?: string;
27
27
  silent?: boolean;
28
- remote?: {
28
+ remoteCredentials?: {
29
29
  accountId?: string;
30
30
  apiToken?: string;
31
+ r2?: {
32
+ accessKeyId: string;
33
+ secretAccessKey: string;
34
+ };
31
35
  };
32
36
  }
33
37
  declare module "nitropack" {
@@ -37,4 +41,5 @@ declare module "nitropack" {
37
41
  }
38
42
  declare function nitroCloudflareDev(arg1: unknown, arg2: unknown): void;
39
43
 
40
- export { type CloudflareDevOptions, type RemoteBinding, nitroCloudflareDev as default };
44
+ export { nitroCloudflareDev as default };
45
+ export type { CloudflareDevOptions, RemoteBinding };
package/dist/index.d.ts CHANGED
@@ -25,9 +25,13 @@ interface CloudflareDevOptions {
25
25
  environment?: string;
26
26
  persistDir?: string;
27
27
  silent?: boolean;
28
- remote?: {
28
+ remoteCredentials?: {
29
29
  accountId?: string;
30
30
  apiToken?: string;
31
+ r2?: {
32
+ accessKeyId: string;
33
+ secretAccessKey: string;
34
+ };
31
35
  };
32
36
  }
33
37
  declare module "nitropack" {
@@ -37,4 +41,5 @@ declare module "nitropack" {
37
41
  }
38
42
  declare function nitroCloudflareDev(arg1: unknown, arg2: unknown): void;
39
43
 
40
- export { type CloudflareDevOptions, type RemoteBinding, nitroCloudflareDev as default };
44
+ export { nitroCloudflareDev as default };
45
+ export type { CloudflareDevOptions, RemoteBinding };
package/dist/index.mjs CHANGED
@@ -174,10 +174,7 @@ Remote bindings: ${remoteBindings.map((b) => `${b.name} (${b.type})`).join(", ")
174
174
  persistDir,
175
175
  environment: nitro.options.cloudflareDev?.environment,
176
176
  remoteBindings,
177
- remoteCredentials: {
178
- accountId: nitro.options.cloudflareDev?.remote?.accountId || process.env.CF_ACCOUNT_ID,
179
- apiToken: nitro.options.cloudflareDev?.remote?.apiToken || process.env.CF_API_TOKEN
180
- }
177
+ remoteCredentials: nitro.options.cloudflareDev?.remoteCredentials
181
178
  };
182
179
  nitro.options.externals.inline = nitro.options.externals.inline || [];
183
180
  nitro.options.externals.inline.push(
@@ -47,29 +47,38 @@ async function _getPlatformProxy() {
47
47
  proxyOptions.environment = runtimeConfig.wrangler.environment;
48
48
  }
49
49
  const proxy = await getPlatformProxy(proxyOptions);
50
- if (remoteBindings.length > 0 && remoteCredentials.accountId && remoteCredentials.apiToken) {
50
+ const { accountId, apiToken, r2 } = remoteCredentials;
51
+ if (!accountId || !apiToken) {
52
+ console.warn("config remoteCredentials is empty. then remote is not working");
53
+ }
54
+ if (remoteBindings.length > 0 && accountId && apiToken) {
55
+ const config = { accountId, apiToken };
51
56
  const { createR2Binding, createKVBinding, createD1Binding } = await import("openwrangler");
52
- const bindingsConfig = {
53
- accountId: remoteCredentials.accountId,
54
- apiToken: remoteCredentials.apiToken
55
- };
56
57
  for (const binding of remoteBindings) {
57
58
  switch (binding.type) {
58
59
  case "r2": {
59
60
  if (binding.bucketName) {
60
- proxy.env[binding.name] = createR2Binding(bindingsConfig, binding.bucketName);
61
+ if (r2) {
62
+ proxy.env[binding.name] = createR2Binding({
63
+ ...config,
64
+ r2AccessKeyId: r2.accessKeyId,
65
+ r2SecretAccessKey: r2.secretAccessKey
66
+ }, binding.bucketName);
67
+ } else {
68
+ console.warn("remoteCredentials r2 is empty, then remote is not working");
69
+ }
61
70
  }
62
71
  break;
63
72
  }
64
73
  case "kv": {
65
74
  if (binding.namespaceId) {
66
- proxy.env[binding.name] = createKVBinding(bindingsConfig, binding.namespaceId);
75
+ proxy.env[binding.name] = createKVBinding(config, binding.namespaceId);
67
76
  }
68
77
  break;
69
78
  }
70
79
  case "d1": {
71
80
  if (binding.databaseId) {
72
- proxy.env[binding.name] = createD1Binding(bindingsConfig, binding.databaseId);
81
+ proxy.env[binding.name] = createD1Binding(config, binding.databaseId);
73
82
  }
74
83
  break;
75
84
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bino0216/nitro-cloudflare-dev",
3
3
  "private": false,
4
- "version": "0.2.4",
4
+ "version": "0.2.6",
5
5
  "description": "POC module to enable access to the Cloudflare runtime bindings in development server of Nitro and Nuxt",
6
6
  "repository": "pi0/nitro-cloudflare-dev",
7
7
  "license": "MIT",
@@ -22,14 +22,11 @@
22
22
  "files": [
23
23
  "dist"
24
24
  ],
25
- "resolutions": {
26
- "@binochoi/nitro-cloudflare-dev": "workspace:*"
27
- },
28
25
  "dependencies": {
29
26
  "consola": "^3.4.0",
30
27
  "mlly": "^1.7.4",
31
- "openwrangler": "^0.0.1",
32
- "pkg-types": "^2.1.0"
28
+ "pkg-types": "^2.1.0",
29
+ "openwrangler": "0.0.4"
33
30
  },
34
31
  "devDependencies": {
35
32
  "@cloudflare/workers-types": "^4.20250303.0",
@@ -44,8 +41,7 @@
44
41
  "nuxt": "^3.15.4",
45
42
  "prettier": "^3.5.3",
46
43
  "typescript": "^5.8.2",
47
- "unbuild": "^3.5.0",
48
- "wrangler": "^3.113.0"
44
+ "unbuild": "^3.5.0"
49
45
  },
50
46
  "publishConfig": {
51
47
  "access": "public"