charter

module
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2026 License: MIT

README

charter

check latest release

Contract-first APIs on Cloudflare Workers, with Huma in Go or oRPC in TypeScript. Write the contract once and get the server, the OpenAPI and AsyncAPI specs, typed SDKs in any language (Fern), a CLI, an MCP endpoint and real-time streams: generated from that contract, and tested.

If you use Huma, this is how it runs on Workers (workers-go and TinyGo) at the cost of a TypeScript Worker. If you use oRPC, this is your contract turned into SDKs, a CLI and an AsyncAPI spec that oRPC does not generate itself.

go run github.com/joeblew999/charter/cmd/charter@latest new -name billing-api -module github.com/you/billing-api
cd billing-api && mise install && mise run setup && mise run check   # a working API, checked locally
mise run deploy                                                       # on Cloudflare

Needs mise, Go and git, on macOS, Linux or Windows (what is covered on Windows). Then: Getting started.

What you get

  • The contract is the source. Huma operations in Go (structs and tags), or an oRPC contract in TypeScript (Zod). Change it, run mise run spec, and everything downstream follows. A stale spec fails the check.
  • Huma on Cloudflare Workers at TypeScript's cost. Under 1 ms of CPU for a simple read, 1 to 2 ms with a database read, about 2 ms for a write: the same as the TypeScript Worker, measured side by side (benchmarks). TinyGo and workers-go as they come cost 55 to 265 ms; the build and the Worker glue here are what close the gap.
  • SDKs for other developers, in their language. Fern generates Go and TypeScript clients and a CLI from the specs; add a language with one block of configuration. A tagged release publishes them.
  • Real-time that does not lose messages. SSE and WebSocket feeds that survive redeploys, dropped connections and idle hours, with a client rule and a soak test that proves it.
  • An MCP endpoint from the same contract: every operation that answers once is a tool, for agents.
  • One way to run everything. mise run <task> does the same thing on your machine, in GitHub Actions and in a project made from this one.

What is in this repository

Folder What it is
go/ The Go library a project imports: Huma on Workers (humaworkers), the request bridge (transport), D1 (d1), the hub (hub), the gap-free feed (follow), MCP from a Huma API (humamcp), AsyncAPI for Huma (asyncapi)
examples/ Four complete projects: the notes API and a showcase of every Fern feature, each in Go and in TypeScript. charter new copies the Go notes one
cmd/charter/ The tool behind every task: build, bench, generate, release, scaffold
docs/ Everything else: start here, rendered at https://joeblew999.github.io/charter/

Generated files are marked as such and never edited by hand: what is generated.

Status

Used by other projects, released with version tags. TinyGo is used as it ships, with two small runtime patches applied at build time, both reported upstream (upstream issues). To help: How to help.

License

MIT.

Directories

Path Synopsis
cmd
charter command
Command charter is what the mise tasks of a project run: every task in a project's mise.toml is one line, and anything that needs more than one line is a command here.
Command charter is what the mise tasks of a project run: every task in a project's mise.toml is one line, and anything that needs more than one line is a command here.
example module
sdk/go module
examples
notes module
notes-go module
notes/sdk/go module
go module
lib module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL