cf-bindings-proxy
Advanced tools
Comparing version
127
package.json
{ | ||
"name": "cf-bindings-proxy", | ||
"version": "0.2.5", | ||
"description": "Experimental proxy for interfacing with bindings in projects targeting Cloudflare Pages", | ||
"license": "MIT", | ||
"author": "James", | ||
"type": "module", | ||
"bin": "./cli/index.js", | ||
"exports": { | ||
".": { | ||
"import": "./index.js", | ||
"require": "./index.cjs" | ||
} | ||
}, | ||
"publishConfig": { | ||
"directory": "dist" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/james-elicx/cf-bindings-proxy" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/james-elicx/cf-bindings-proxy/issues" | ||
}, | ||
"homepage": "https://github.com/james-elicx/cf-bindings-proxy#readme", | ||
"scripts": { | ||
"dev": "node ./cli/index.js", | ||
"build": "vite build && node ./scripts/build.js", | ||
"build:watch": "npm run build --watch", | ||
"lint": "eslint \"./**/*.{cjs,js,jsx,ts,tsx}\"", | ||
"prettier": "prettier --ignore-unknown --ignore-path=.gitignore --check .", | ||
"prettier:format": "prettier --ignore-unknown --ignore-path=.gitignore --write .", | ||
"tsc": "tsc --noEmit", | ||
"test": "vitest run", | ||
"test:kill": "rm -rf .wrangler; sudo kill -9 `sudo lsof -i :8799 -t`", | ||
"test:watch": "vitest", | ||
"test:coverage": "vitest run --coverage", | ||
"alter-version": "node ./scripts/alter-version.js", | ||
"release": "changeset publish" | ||
}, | ||
"devDependencies": { | ||
"@changesets/cli": "^2.26.2", | ||
"@cloudflare/workers-types": "^4.20230710.1", | ||
"@tsconfig/strictest": "^2.0.1", | ||
"@types/node": "^20.3.3", | ||
"eslint": "^8.41.0", | ||
"eslint-config-ixn": "^1.4.2", | ||
"kysely": "^0.26.1", | ||
"kysely-d1": "^0.3.0", | ||
"nodemon": "^2.0.22", | ||
"prettier": "^2.8.8", | ||
"typescript": "^5.0.4", | ||
"vite": "^4.3.5", | ||
"vite-plugin-dts": "^2.3.0", | ||
"vite-plugin-externalize-deps": "^0.6.0", | ||
"vitest": "^0.31.0", | ||
"vitest-environment-miniflare": "^2.14.0", | ||
"wrangler": "^3.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@cloudflare/workers-types": ">=4", | ||
"wrangler": ">=3.0.0" | ||
} | ||
"name": "cf-bindings-proxy", | ||
"version": "0.2.6-84b0638", | ||
"description": "Experimental proxy for interfacing with bindings in projects targeting Cloudflare Pages", | ||
"license": "MIT", | ||
"author": "James", | ||
"type": "module", | ||
"bin": "./cli/index.js", | ||
"exports": { | ||
".": { | ||
"import": "./index.js", | ||
"require": "./index.cjs" | ||
} | ||
}, | ||
"publishConfig": { | ||
"directory": "dist" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/james-elicx/cf-bindings-proxy" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/james-elicx/cf-bindings-proxy/issues" | ||
}, | ||
"homepage": "https://github.com/james-elicx/cf-bindings-proxy#readme", | ||
"scripts": { | ||
"dev": "node ./cli/index.js", | ||
"build": "vite build && node ./scripts/build.js", | ||
"build:watch": "npm run build --watch", | ||
"lint": "eslint \"./**/*.{cjs,js,jsx,ts,tsx}\"", | ||
"prettier": "prettier --ignore-unknown --ignore-path=.gitignore --check .", | ||
"prettier:format": "prettier --ignore-unknown --ignore-path=.gitignore --write .", | ||
"tsc": "tsc --noEmit", | ||
"test": "vitest run", | ||
"test:kill": "rm -rf .wrangler; sudo kill -9 `sudo lsof -i :8799 -t`", | ||
"test:watch": "vitest", | ||
"test:coverage": "vitest run --coverage", | ||
"alter-version": "node ./scripts/alter-version.js", | ||
"release": "changeset publish" | ||
}, | ||
"devDependencies": { | ||
"@changesets/cli": "^2.26.2", | ||
"@cloudflare/workers-types": "^4.20230814.0", | ||
"@tsconfig/strictest": "^2.0.1", | ||
"@types/node": "^20.3.3", | ||
"eslint": "^8.41.0", | ||
"eslint-config-ixn": "^1.4.2", | ||
"kysely": "^0.26.1", | ||
"kysely-d1": "^0.3.0", | ||
"nodemon": "^2.0.22", | ||
"prettier": "^2.8.8", | ||
"typescript": "^5.0.4", | ||
"vite": "^4.3.5", | ||
"vite-plugin-dts": "^2.3.0", | ||
"vite-plugin-externalize-deps": "^0.6.0", | ||
"vitest": "^0.31.0", | ||
"vitest-environment-miniflare": "^2.14.0", | ||
"wrangler": "^3.5.1" | ||
}, | ||
"peerDependencies": { | ||
"@cloudflare/workers-types": ">=4", | ||
"wrangler": ">=3.0.0" | ||
}, | ||
"versionMetadata": { | ||
"type": "BETA" | ||
} | ||
} |
21
proxy.js
@@ -1,2 +0,2 @@ | ||
import { transformData as _ } from "./transform.js"; | ||
import { transformData as a } from "./transform.js"; | ||
const c = async (i) => { | ||
@@ -8,2 +8,3 @@ let s; | ||
method: "POST", | ||
cache: "no-store", | ||
headers: { "Content-Type": "application/json" } | ||
@@ -17,4 +18,4 @@ }); | ||
throw new Error(t || "Bad response from binding proxy"); | ||
return r ? _(t, r) : t; | ||
}, a = (i, s, n) => new Proxy(n, { | ||
return r ? a(t, r) : t; | ||
}, _ = (i, s, n) => new Proxy(n, { | ||
get(t, r) { | ||
@@ -27,12 +28,12 @@ if (!n || ["then", Symbol.iterator, Symbol.toStringTag].includes(r)) | ||
return n[Number(r)]; | ||
const e = l(i, !0); | ||
return e.__original_call = s, async (...o) => (e.__calls.push({ prop: r, args: o }), c(e)); | ||
const e = o(i, !0); | ||
return e.__original_call = s, async (...l) => (e.__calls.push({ prop: r, args: l }), c(e)); | ||
} | ||
}), u = (i) => ["prepare"].includes(i) ? ["first", "run", "all", "raw"] : [], l = (i, s = !1) => new Proxy({ __bindingId: i, __calls: [], __chainUntil: [] }, { | ||
}), u = (i) => ["prepare"].includes(i) ? ["first", "run", "all", "raw"] : [], o = (i, s = !1) => new Proxy({ __bindingId: i, __calls: [], __chainUntil: [] }, { | ||
get(n, t) { | ||
if (t.startsWith("__")) | ||
if (typeof t == "string" && t.startsWith("__")) | ||
return n[t]; | ||
if (t !== "toJSON" && !s) { | ||
if (n.__chainUntil.length || (n.__chainUntil = u(t)), n.__chainUntil.length && !n.__chainUntil.includes(t)) { | ||
const r = l(i); | ||
const r = o(i); | ||
return r.__chainUntil = n.__chainUntil, r.__calls = n.__calls, (...e) => (n.__calls.push({ prop: t, args: e }), r); | ||
@@ -43,3 +44,3 @@ } | ||
const e = await c(n); | ||
return typeof e != "object" || !e ? e : a(i, n, e); | ||
return typeof e != "object" || !e ? e : _(i, n, e); | ||
}; | ||
@@ -50,4 +51,4 @@ } | ||
export { | ||
l as createBindingProxy | ||
o as createBindingProxy | ||
}; | ||
//# sourceMappingURL=proxy.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
50374
0.86%237
0.42%