Deploys cloudflare workers without the overhead of wrangler/node
Emil Lerch
533ab89fe9
The wrangler project does some bundling for us, that we are not ready to reproduce here. So for the time being, we will do this manually |
||
---|---|---|
src | ||
.gitignore | ||
build.zig | ||
LICENSE | ||
README.md |
Upload worker to CloudFlare
Until we're better
- Add
accountid.txt
tosrc/
with the CloudFlare account id - Add
worker_name.txt
tosrc/
with CloudFlare worker name zig build run
Getting new index.js
- Run a real wrangler deploy, then go into the console and copy/paste
Steps we take:
- Check if the worker exists: GET https://api.cloudflare.com/client/v4/accounts//workers/services/<worker_name> 404 - does not exist
- Add the "script" PUT https://api.cloudflare.com/client/v4/accounts//workers/scripts/<worker_name>?include_subdomain_availability=true&excludeScript=true
- Get the "subdomain". I believe this is simply to determine the test url: GET https://api.cloudflare.com/client/v4/accounts//workers/subdomain
- Enable the script: This is only done if the script did not exist. Subsequent flows leave this alone POST https://api.cloudflare.com/client/v4/accounts//workers/scripts/<worker_name>/subdomain Data: { "enabled": true }