chientrm / wrangler-proxy Goto Github PK
View Code? Open in Web Editor NEWWrangler Proxy exposes Workers API to outside and integrate to your favorite frameworks. Compatible with DrizzleORM.
License: MIT License
Wrangler Proxy exposes Workers API to outside and integrate to your favorite frameworks. Compatible with DrizzleORM.
License: MIT License
The example code
waitUntil(async () => {}, platform?.context);
has an error
Argument of type '() => Promise<void>' is not assignable to parameter of type 'Promise<any>'.ts(2345)
Perhaps it should be like this?
waitUntil((async () => {})(), platform?.context);
Are there any plans to implement list operation for KV?
If not, I would be keen to help out in this open source repository.
When I am running the proxy, the "PUT" command for R2 is not returning anything. It's returning null
but on CF it returns an object.
const file = form.get('file');
const image = await locals.R2.put(`${fileName}.${ext}`, file);
if (!image) {
error(500, {
title: 'Failed to upload image.',
detail: 'Something went wrong when trying to save your save your image.'
});
}
This code fails because image
is null, even though it gets properly uploaded via proxy bindings - but does not fail when hosted on CF.
I've got the setup with a small Svelte project, and any attempt to use a PUT operation with R2 fails.
const r2 = event.platform?.env.TORCH_R2 ?? connectR2('R2_STORE');
if (!r2) throw new Error('Torch R2 binding not found');
await r2.put('newvalue', 'test'); <-- stack points here
Wrangler-proxy Console Error:
[wrangler:inf] POST /instruction 200 OK (2ms)
[wrangler:inf] POST /data 500 Internal Server Error (3ms)
Svelte Console Error
Error: {"name":"TypeError","message":"Provided readable stream must have a known length (request/response body or readable half of FixedLengthStream)","stack":"TypeError: Provided readable stream must have a known length (request/response body or readable half of FixedLengthStream)"}
at W (file:///C:/Users/XXX/development/svelte-test/node_modules/wrangler-proxy/dist/index.js:1:197)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async o.post (file:///C:/Users/XXX/development/svelte-test/node_modules/wrangler-proxy/dist/index.js:1:714)
at async Module.init (C:\Users\XXX\development\svelte-test\src\lib\middleware\init.ts:29:3)
at async Object.handle (C:\Users\XXX\development\svelte-test\src\hooks.server.ts:9:14)
at async Module.respond (C:\Users\XXX\development\svelte-test\node_modules\@sveltejs\kit\src\runtime\server\respond.js:282:20)
at async file:///C:/Users/XXX/development/svelte-test/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:502:22
j {
host: 'http://127.0.0.1:8787',
name: 'R2_STORE',
metadata: {},
data: null <-- null?
}
It looks like data
is null, but I am passing a value.
OK not sure if this is a problem with the proxy, but when attempting to use DrizzleORM and do a findFirst() query I'm getting the following error:
The same table running a query with findMany() works fine.. Also getting similar errors on any queries that involve where clauses.. Is there some query translation problem?
Hi,
I want to use CF and D1 for building a project using SvelteKit and its prerender feature.
Prerender is done at build time with vanilla node, not wrangler, so no bindings are available.
But HTTP requests are allowed and we can call APIs with HTTP.
I'll do this because the Query API is simple.
I also need D1 at runtime so I can use D1 bindings in this case.
But I wondering if this great wrangler-proxy project can perform API calls directly on the D1 HTTP endpoint, by providing in environment variables kind of CF_ACCOUNT_ID, CF_D1_DB_ID, CF_D1_DB_TOKEN.
For now, I just need simple query and I have no time to contribute but maybe one day.
Thx.
Goal is to re-size image and then upload to R2 - so the idea was to use the service binding fetch()
to re-size an image so I can then upload it to R2 - but I wasn't exactly sure if it was implemented.
I see that fetch()
is proxied, but I am getting Error: Method not implemented.
when trying to call the fetch request with cf-image
options.
Perhaps I am doing this incorrectly? Is there an example of this possibly?
When I want to try catch errors I get errors like:
โ{"status":500,"statusText":"Internal Server Error","message":"{\"name\":\"Error\",\"message\":\"D1_ERROR: UNIQUE constraint failed: user.username\",\"stack\":\"Error: D1_ERROR: UNIQUE constraint failed: user.username\\n at D1Database._sendOrThrow (cloudflare-internal:d1-api:66:19)\\n at async D1Database.batch (cloudflare-internal:d1-api:35:22)\\n at async o6.execute (file:///Users/shyim/Downloads/shopmon/.wrangler/tmp/dev-koxavv/worker.js:170:132)\\n at async Object.fetch (file:///Users/shyim/Downloads/shopmon/.wrangler/tmp/dev-koxavv/worker.js:449:29)\\n at async jsonError (file:///Users/shyim/Downloads/shopmon/.wrangler/tmp/dev-koxavv/worker.js:469:12)\"}"}
The real error is inside the message as JSON. Therefore such checks in libraries are not working:
https://github.com/lucia-auth/lucia/blob/main/packages/adapter-sqlite/src/drivers/d1.ts#L58-L64
Hello!
Since https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%403.24.0 it is now possible to do the following:
import { getBindingsProxy } from "wrangler";
const { bindings, dispose } = await getBindingsProxy();
try {
const myKv = bindings.MY_KV;
const kvValue = await myKv.get("my-kv-key");
console.log(`KV Value = ${kvValue}`);
} finally {
await dispose();
}
The PR is cloudflare/workers-sdk#4523
@chientrm Maybe you already know about this, I wanted to mention it, in my context I first used wrangler-proxy
, to query D1, which worked great! And now switched to getBindingsProxy
and it also works great! I like how it's an official feature now ๐๐ผ
So, I'm not sure what it means for this project here, if you see the need to continue or to recommend getBindingsProxy
instead? Just curious about your thoughts.
Hi.
Just trying out this repo. It looks like that KV proxy isn't fully implemented
Error: Method not implemented.
at v.getWithMetadata (file:///.../node_modules/wrangler-proxy/dist/index.js:1:9379)
This looks great! Have struggled so much with this in my SvelteKit apps. Any plans to add support for
Main ones for me right now are Durable objects and Queues
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.