clone

push a directory of html from the terminal and get a four-character url back. a deno cli on cloudflare

codex/agent-interface
nzip / worker / setup.md
setup.md 2.4K rendered
1# One-time Cloudflare setup23Everything here happens once. Day-to-day content pushes never touch wrangler.45```sh6cd worker78# 1. auth9npx wrangler login1011# 2. private Wrangler config12cp wrangler.local.example.jsonc wrangler.local.jsonc13# Edit wrangler.local.jsonc now:14# - routes[0].pattern: your hostname, such as share.example.com15# - vars.PUBLIC_BASE: https://<that hostname>16# - d1_databases[0].database_id: filled in after D1 creation1718# 3. storage19npx wrangler r2 bucket create nzip-content20npx wrangler d1 create nzip21# -> paste the printed database_id into wrangler.local.jsonc2223# 4. schema24npx wrangler d1 execute nzip --remote --file schema.sql2526# 5. owner token27openssl rand -hex 32 # keep this — it's your CLI token28npx wrangler secret put NZIP_TOKEN --config wrangler.local.jsonc2930# 6. first deploy31npx wrangler deploy --config wrangler.local.jsonc32```3334`routes[0].pattern` and `vars.PUBLIC_BASE` are required user-provided values. `PUBLIC_BASE` is the35origin printed in share URLs and the server URL passed to `nzip auth`.3637> **Cron gotcha:** deploying the `triggers` block fails with a 403 (API error `10063`) until the38> account has a workers.dev subdomain registered — even if the Worker only serves a custom domain.39> Open the Workers dashboard once to auto-create it, or `PUT /accounts/{id}/workers/subdomain` with40> `{"subdomain":"<name>"}`.4142## Required custom domain43441. Add your zone to your Cloudflare account (registrar -> Cloudflare nameservers).452. In `wrangler.local.jsonc`, set `routes[0].pattern`, `vars.PUBLIC_BASE`, and your D146 `database_id`.473. `npx wrangler deploy --config wrangler.local.jsonc` - the custom-domain route provisions DNS +48 cert automatically.4950## CLI5152```sh53# from the repo root54deno install -g -f -n nzip \55 --allow-net --allow-read --allow-write --allow-env \56 cli/main.ts5758nzip auth --server https://share.example.com --token <token-from-step-5>59nzip vault add personal # slot 0x060nzip vault add work # slot 0x161nzip push ./docs personal:plan --ttl forever62```6364## Local development6566```sh67cd worker68npx wrangler d1 execute nzip --local --file schema.sql # once69npx wrangler dev # local R2/D1, token from .dev.vars70nzip auth --server http://localhost:8787 --token dev-token-local-only71```7273Test the GC cron locally: run `wrangler dev --test-scheduled`, then74`curl "http://localhost:8787/__scheduled?cron=0+4+*+*+*"`.