clone

nostr relays on demand at <name>.bind.ws: claim one with your key, pay in zaps past the free allowance

scripts: every tool has an npm name, and the docs, the headers and the workflow use it; a tutorial never says node and a path

Dami committed db08d35
commit
db08d3502ec8c3b65637d0a80c6f65a9af6b0421
parent
8008443ea0763acaa90224ddedbb96c1ca882f18
author
Dami <dami.etoile@gmail.com>
17 files changed, +51 -42
M.github/workflows/margin.yml2+-
Mdocs/00-getting-started.md8++++----
Mdocs/11-hosting-bindws.md4++--
Mdocs/12-develop-extend.md11++++++-----
Mdocs/13-scripts-and-agents.md10+++++-----
Mdocs/15-costs-and-margins.md6+++---
Mdocs/16-hosting-without-cloudflare.md2+-
Mpackage.json12++++++++++--
Mrelay-templates/README.md4++--
Mscripts/check/check-config.mjs6+++---
Mscripts/dev/junk.mjs2+-
Mscripts/dev/seed.mjs2+-
Mscripts/dev/shot.mjs2+-
Mscripts/dev/stage.mjs2+-
Mscripts/dev/zaptest.mjs2+-
Mscripts/ops/margin.mjs8++++----
Mscripts/ops/relay.mjs10+++++-----
M .github/workflows/margin.yml +1 -1
M docs/00-getting-started.md +4 -4
M docs/11-hosting-bindws.md +2 -2
@@ -22,7 +22,7 @@ Edit `wrangler.jsonc`:
2222 | `LEASE_DAYS` | how long a temporary relay from `POST /lease` lives; 14 if unset |2323 | `ratelimits` | how many leases a minute, per address and overall; the defaults are 5 and 60 |2424 25-The prices carry a comment with the Cloudflare rates they were set from. `node scripts/ops/margin.mjs` compares them with those rates at the current bitcoin price, and a weekly workflow does the same; see [Costs and margins](15-costs-and-margins.md).25+The prices carry a comment with the Cloudflare rates they were set from. `npm run margin` compares them with those rates at the current bitcoin price, and a weekly workflow does the same; see [Costs and margins](15-costs-and-margins.md).2626 2727 Point `routes` at your zone: the apex as a custom domain and `*.<domain>/*` as a zone route. Create the R2 bucket named in `r2_buckets`.2828
@@ -126,4 +126,4 @@ npm run dev
126126 127127 `wrangler dev --env dev` serves `http://<name>.localhost:8787` as the relay named `<name>`, `http://<domain>.localhost:8787` as the apex and anything else as `DEV_RELAY`. The dev environment has no routes, so hostnames pass through.128128 129-To use the console without a browser extension, run `node scripts/dev/dev-signer.mjs` and paste the snippet from that file into the devtools console before clicking sign in. `node scripts/dev/seed.mjs <name>` publishes sample events. `npm run dev` folds the console's files into their generated module first; the templates need `npm run build:templates` after a change.129+To use the console without a browser extension, run `npm run dev:signer` and paste the snippet from that file into the devtools console before clicking sign in. `npm run dev:seed <name>` publishes sample events. `npm run dev` folds the console's files into their generated module first; the templates need `npm run build:templates` after a change.
M docs/12-develop-extend.md +6 -5
@@ -62,9 +62,10 @@ scripts/
6262 build-console.mjs fold src/console into src/gen/console.ts6363 build-templates.mjs fold relay-templates/ into src/gen/templates.ts6464 check/ check-console.mjs check-celld.mjs check-config.mjs run by npm run typecheck; check-config also checks any file65- dev/ dev-signer.mjs seed.mjs stage.mjs junk.mjs shot.mjs zaptest.mjs for a dev relay66- ops/ margin.mjs fuel prices against Cloudflare's rates, weekly in CI67- relay.mjs check, plan, push or pull a relay's configuration file65+ dev/ dev-signer.mjs seed.mjs stage.mjs junk.mjs shot.mjs zaptest.mjs npm run dev:signer, dev:seed, dev:stage, dev:junk, dev:shot, dev:zaptest66+ ops/ margin.mjs relay.mjs npm run margin; npm run relay check|plan|push|pull67+68+Every script has an npm name (package.json), and the docs use those names: a tutorial never says node and a path.6869 wrangler.jsonc the Worker on Cloudflare6970 wrangler.celld.jsonc the same Worker on celld (docs/16)7071 ```
@@ -117,13 +118,13 @@ Remote signing needs NIP-44 and secp256k1, which browsers do not ship. `scripts/
117118 118119 The console is three ordinary files in `src/console`: `console.html` (the body), `console.css` and `console.js`. `npm run build:console` folds them into `src/gen/console.ts`, the strings the relay serves; `npm run dev` runs it first, and `npm run typecheck` fails when the generated file is stale. It is a generated module rather than a text-module rule in `wrangler.jsonc` because celld deploy refuses a config with `rules`. `scripts/check/check-console.mjs` runs the script's synchronous start against a stub document, so a handler wired above the helper it calls fails typecheck instead of a live page. The shared shell in `ui.ts` provides fonts, colors, buttons, inputs and the sticker vocabulary; keep new pages inside it.119120 120-To look at what you changed: `npm run dev`, then `node scripts/dev/dev-signer.mjs`, open `http://<name>.localhost:8787/`, paste the `window.nostr` snippet from that script into the devtools console, and sign in or claim. Playwright's CLI can drive the same loop: open the page, inject the snippet with `eval`, click, screenshot at a phone width and at a desktop width. `scripts/dev/shot.mjs` renders a page over the Chrome debugging protocol when Playwright is not around.121+To look at what you changed: `npm run dev`, then `npm run dev:signer`, open `http://<name>.localhost:8787/`, paste the `window.nostr` snippet from that script into the devtools console, and sign in or claim. Playwright's CLI can drive the same loop: open the page, inject the snippet with `eval`, click, screenshot at a phone width and at a desktop width. `scripts/dev/shot.mjs` renders a page over the Chrome debugging protocol when Playwright is not around.121122 122123 Rules that hold across pages: no middle dots, no purposeless subtext, tables scroll inside their card on narrow screens, decorative elements are not selectable, a multi-field form uses the labelled grid rather than one row of inputs, and the copy above a block is one sentence.123124 124125 ## Screenshots125126 126-`node scripts/dev/shot.mjs <url> <out.png> [width] [height]` renders a page with phone or desktop emulation over the Chrome debugging protocol and prints the layout's scroll width, which should equal the viewport width.127+`npm run dev:shot <url> <out.png> [width] [height]` renders a page with phone or desktop emulation over the Chrome debugging protocol and prints the layout's scroll width, which should equal the viewport width.127128 128129 ## Pull requests129130
M docs/13-scripts-and-agents.md +5 -5
@@ -168,13 +168,13 @@ The bridge takes the same header. `POST /events` answers `{ event_id, accepted,
168168 169169 `exportconfig` is a document, and a document can live in a repository. The format is `bind.ws/relay-config/2`: `policy`, `members`, `bans`, `addresses`, `banned_events`, `kinds` and `retention`, each a section, and a section the file leaves out is left alone when it is applied, so a file may carry the rules and nothing about people. The schema is at `https://bind.ws/relay-config.schema.json`; put it in `$schema` and the editor checks the file as you type. JSONC is fine: comments and trailing commas.170170 171-Four verbs, in `scripts/ops/relay.mjs`, with `RELAY_SK` holding the owner's key as hex or nsec:171+Four verbs, run from a checkout of the repository with `RELAY_SK` holding the owner's key as hex or nsec:172172 173173 ```174-node scripts/ops/relay.mjs check relay.jsonc # the schema and the relay's own parser, offline175-node scripts/ops/relay.mjs plan relay.jsonc wss://name.bind.ws # what applying would change; touches nothing176-node scripts/ops/relay.mjs push relay.jsonc wss://name.bind.ws # the plan, then the change177-node scripts/ops/relay.mjs pull wss://name.bind.ws relay.json # the relay as it is, into a file174+npm run relay check relay.jsonc # the schema and the relay's own parser, offline175+npm run relay plan relay.jsonc wss://name.bind.ws # what applying would change; touches nothing176+npm run relay push relay.jsonc wss://name.bind.ws # the plan, then the change177+npm run relay pull wss://name.bind.ws relay.json # the relay as it is, into a file178178 ```179179 180180 `check` fails on anything a relay would drop, since a silently dropped entry is a mistake in a file under source control. `plan` is `importconfig` with `{ dryRun: true }`: the answer lists the changes section by section with a `summary` line each, plus the entries the relay would not take. `pull` then `git diff` shows drift between the file and the relay.
M docs/15-costs-and-margins.md +3 -3
M docs/16-hosting-without-cloudflare.md +1 -1
M package.json +10 -2
M relay-templates/README.md +2 -2
M scripts/check/check-config.mjs +3 -3
M scripts/dev/junk.mjs +1 -1
M scripts/dev/seed.mjs +1 -1
M scripts/dev/shot.mjs +1 -1
M scripts/dev/stage.mjs +1 -1
M scripts/dev/zaptest.mjs +1 -1
M scripts/ops/margin.mjs +4 -4
M scripts/ops/relay.mjs +5 -5