Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudflare Workers Tutorial Boilerplate WASM WASI #138

Open
dtruffaut opened this issue Sep 30, 2022 · 3 comments
Open

Cloudflare Workers Tutorial Boilerplate WASM WASI #138

dtruffaut opened this issue Sep 30, 2022 · 3 comments

Comments

@dtruffaut
Copy link

dtruffaut commented Sep 30, 2022

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 :)

@silvia-odwyer
Copy link
Owner

@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!

@saibotrellum
Copy link

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!

@ccbikai
Copy link

ccbikai commented Dec 18, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants