web: render /crawl in the site shell - #1
Merged
Merged
Conversation
The x402 gateway's sales page was its own bare HTML: system font, no top bar, no footer, none of the site's tokens. It was the one page on r4ck.dev that did not look like r4ck.dev. The gateway takes a `page(ctx)` renderer, so /crawl now renders through the Layout like every other route, with the same words and every number still read off the gateway's context. The hook must answer with a string, so the asset-version helper moves to lib/assets.js and reads synchronously, which lets the Layout drop its awaits. Static serving keeps using the same helper. Tests cover the string render inside the shell, the throttled and multi-day variants, escaping, and the gateway serving it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
https://r4ck.dev/crawl was the x402 gateway's own bare HTML page: system font, no top bar, no footer, none of the site's tokens. The one page on the site that did not look like the site.
@profullstack/x402-gatewaytakes apage(ctx)renderer, so/crawlnow renders through the siteLayoutlike every other route. Same words, every number still read off the gateway's context (price, days, header, networks, charged and free crawler lists, the verbatim offer). The throttled variant ("You have used up the free allowance") and the?days=Nvariant render too.How
routes/static.jstolib/assets.jsand hashes synchronously (readFileSync+Bun.CryptoHasher, once per asset per process), so theLayoutdrops its three awaits and is a plain function.views/crawl.jsxis the page;renderCrawl(ctx)throws loudly if the tree ever renders async instead of putting[object Promise]on a live page.lib/gate.jspassespage: renderCrawl. The page keepsnoindex.Tests
bun test: 39 pass, 2 skip (the two that needDATABASE_URL). Newtest/crawl.test.jscovers the string render inside the shell, throttled and multi-day variants, escaping, andgateway.page().bun run lintclean.Also ran the gateway's real
handle()with a GPTBot user agent against/crawl?days=3: 402,text/html,<title>Crawl pass · r4ck</title>, top bar present, quotes3.00 USD for 3 × one day.🤖 Generated with Claude Code