Skip to content

Refresh Stock Reservation example: Hono, Bun.SQL and ClickHouse Managed Postgres - #505

Merged
sdairs merged 1 commit into
mainfrom
refresh/stock-reservation
Oct 23, 2026
Merged

sdairs merged 1 commit into
mainfrom
refresh/stock-reservation

Conversation

@sdairs

@sdairs sdairs commented Oct 22, 2026

Copy link
Copy Markdown
Member

Refreshes applications/stock-reservation (Hono, Bun 1.4.2 and Bun.SQL on ClickHouse Managed Postgres) to the standard example shape. App behaviour, dependency versions and the lockfile are unchanged.

README: cut from 512 to about 260 lines. It now has:

  • a Stack table and a section on connecting Bun.SQL to ClickHouse Managed Postgres
  • the standard clickhousectl provisioning, schema and run steps
  • a Try it section that ends with eight concurrent buyers competing for five units
  • Test, an agent prompt, Limits and Clean up

Environment-specific setup instructions are removed.

Other changes:

  • The SQL files are renamed to sql/01_roles.sql, 02_grants.sql, 03_seed.sql and 99_cleanup.sql. The password variables are now MIGRATOR_PASSWORD and APP_PASSWORD. sql/migrations/001_initial.sql and src/database.ts keep their paths.
  • The Bun 1.4.2 CA bundle explanation is now a comment in src/database.ts.
  • tests/README.md is folded into the README's Test section, and the example's AGENTS.md is removed.
  • bun run test now runs the typecheck before the unit tests. CI is unchanged apart from a comment.
  • The root README's duplicated applications row is merged into one.

Verified against ClickHouse Managed Postgres 18.6:

  • The README's provisioning, schema, run and cleanup steps ran exactly as written.
  • The Try it steps returned the documented responses. In the race, 5 requests got 201 and 3 got 409.
  • 11 unit tests pass. 17 integration and TLS tests also pass, covering:
    • 32 buyers competing for 9 units
    • 24 simultaneous retries with one key
    • 20 concurrent releases
    • rollback when a write fails
    • client ownership
    • app-role privileges
    • rejection of a wrong CA and a wrong hostname
  • The CI steps pass on a clean copy of the branch.

Walkthrough article: https://clickhouse.com/resources/engineering/build-stock-reservation-api-hono-bun-postgres

🤖 Generated with Claude Code

Restructure the README as a reference: Stack table, a standalone
"Connect Bun.SQL to ClickHouse Managed Postgres" section, the standard
clickhousectl provisioning steps, Try it, Test, agent prompt and Limits.
Behaviour is unchanged.

- Rename SQL files to sql/01_roles, 02_grants, 03_seed, 99_cleanup and
  the password variables to MIGRATOR_PASSWORD / APP_PASSWORD
- Move the Bun CA bundle note into src/database.ts
- Fold tests/README.md into the README Test section and remove the
  example's AGENTS.md
- `bun run test` now typechecks before the unit tests
- Fix the duplicated applications row in the root README

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lio-p
lio-p self-requested a review October 23, 2026 14:28
@sdairs
sdairs merged commit c11eeea into main Oct 23, 2026
1 check passed
@sdairs
sdairs deleted the refresh/stock-reservation branch October 23, 2026 14:40
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

Successfully merging this pull request may close these issues.

2 participants