photon icon indicating copy to clipboard operation
photon copied to clipboard

Cloudflare Workers Tutorial Boilerplate WASM WASI

Open dtruffaut opened this issue 2 years ago • 3 comments

Cloudflare Workers is a popular serverless platform. A tutorial + boilerplate explaining how to setup Photon would be awesome.

Cloudflare Workers supports Photon

Demo https://image-demo.denoflare.dev/ https://denoflare.dev/examples/transform-images-wasm Code https://github.com/skymethod/denoflare/blob/v0.5.8/examples/image-demo-worker/img.ts https://github.com/skymethod/denoflare/blob/9e01b76e6569653c7092a9ab3280e190e146300b/common/import_wasm.ts

Cloudflare Workers supports WASI

Native: https://blog.cloudflare.com/running-zig-with-wasi-on-cloudflare-workers/ Javascript: https://blog.cloudflare.com/announcing-wasi-on-workers/ (Preferred) cargo build --target wasm32-wasi --release

Cloudflare Workers supports Fetch

No need for ~~node-fetch~~, you can fetch directly in Cloudflare Workers const response = await fetch(url, init);

init is basically the request options plus some Cloudflare extra parameters if needed. https://developers.cloudflare.com/workers//runtime-apis/request#requestinit

--

Reducing the deployment friction with a tutorial would facilitate the web developers adoption. This is an opportunity to make Photon super popular.

Thanks :)

dtruffaut avatar Sep 30 '22 23:09 dtruffaut

@dtruffaut Hi Denis, Wow, thank you very much for this! I had a look at the Denoflare demo you linked, and was very impressed by it overall. Cloudflare's WASI support is a very exciting development in the space, and I'm so impressed by Cloudflare Workers' incredible performance! I'll definitely have to set up Photon with Cloudflare Workers in the near future and post a tutorial on it also.

I'll also link to the Denoflare demo in the README of this repo also, so that others can see Photon and Cloudflare Workers in action 🎉

Thanks again!

silvia-odwyer avatar Oct 01 '22 22:10 silvia-odwyer

I'll definitely have to set up Photon with Cloudflare Workers in the near future and post a tutorial on it also.

That would be awesome! Sadly I can't find an example using Photon on Cloudflare without Deno. And a quick read-through of the the Demo code above shows several Deno-specific changes + several includes that seems to hold code for other Demos in this repository. So testing what is (not) needed without Deno or other demo modules is not a quick job (for me, at least :-).

So a short example of how to run on CF without Deno would be greatly appreciated. No need to be as extensive, just some code example with one working image manipulation would already be a huge help.

Thanks!

saibotrellum avatar Mar 10 '23 10:03 saibotrellum

I'll definitely have to set up Photon with Cloudflare Workers in the near future and post a tutorial on it also.

That would be awesome! Sadly I can't find an example using Photon on Cloudflare without Deno. And a quick read-through of the the Demo code above shows several Deno-specific changes + several includes that seems to hold code for other Demos in this repository. So testing what is (not) needed without Deno or other demo modules is not a quick job (for me, at least :-).

So a short example of how to run on CF without Deno would be greatly appreciated. No need to be as extensive, just some code example with one working image manipulation would already be a huge help.

Thanks!

look here https://github.com/ccbikai/cloudflare-worker-image

ccbikai avatar Dec 18 '23 05:12 ccbikai