API reference and stability audit
Every public surface borgo has, catalogued from the source, with a stability marker on each entry. This page exists for two reasons: so you can tell at a glance whether something you are about to depend on is a promise or an experiment, and so the project can see how much unfinished surface stands between here and 1.0.
The rules those markers will mean once 1.0 ships are in api stability. What borgo will and will not grow into is in VISION.md.
How to read this#
| Marker | Meaning |
|---|---|
| stable | We intend to keep it, with this name and this shape, through all of 1.x. |
| provisional | Shipped and usable, but the name or the signature may still change in a minor. Use it; expect a migration note. |
| deprecated | Still works exactly as before, with a named replacement. Removed only in a major, after at least two minors carrying the warning: see api stability. |
| internal | Exported for mechanical reasons — the generated code imports it, or a sibling module needs it. Not for application use, not covered by the stability promise, may change in any release. |
Anything not listed here is not public, whatever its capitalization.
What is catalogued below: the Go exports (struct fields and interface methods included), the TypeScript exports across six entry points, the environment variables, the borgo subcommands plus create-borgo and borgogen, and the file conventions. Deliberately without totals — no test counts any of them, so a number here would go stale between two commits while the tables underneath stayed right. The findings at the end say what to do about each entry still marked provisional or internal.
Go: github.com/LuigiDavideMicca/borgo#
The module is the repository root. It has zero runtime dependencies; golang.org/x/tools is required only by cmd/borgogen.
Routing and server#
| Symbol | What it is for | Stability |
|---|---|---|
Handle(pattern string, h http.HandlerFunc) |
Registers a handler under a "METHOD /path" pattern. Panics on a malformed pattern, a nil handler, a duplicate, or a call after Serve. |
stable |
Serve() |
Mounts every registered route, adds GET /healthz unless an app route claims it, listens: under borgo start or borgo dev on PORT, the public port, with API_PORT on loopback for the render service; with no render service, an api-only app, on API_PORT on every interface, handles signals and graceful shutdown. Blocks, and calls log.Fatal if the listener fails. |
stable |
ServeContext(ctx) error |
The same server, ended by cancelling ctx and returning the error instead of exiting. For embedding in a larger program, and for tests. |
stable |
Middleware(h http.Handler) http.Handler |
The chain Serve installs around its own routes — panic recovery, gzip, and the guard that makes a response carrying Set-Cookie say Cache-Control: private as its headers commit. For an app mounting borgo handlers on a mux of its own; Serve is defined in terms of it. |
stable |
CheckEnv() error |
The startup validation Serve and ServeContext run: BORGO_HASH_SLOTS, SESSION_SECURE, the push variables, SESSION_SECRET length, and since 1.1 BORGO_HOST, BORGO_MAX_INFLIGHT, BORGO_HANDLER_TIMEOUT, BORGO_ACCESS_LOG, BORGO_LOG_FORMAT, BORGO_SHUTDOWN_DELAY and the keys of SESSION_SECRET_PREVIOUS. It also refuses a malformed BORGO_SECURITY_HEADERS, BORGO_CSP, BORGO_HSTS, BORGO_PERMISSIONS_POLICY, BORGO_LOGIN_ATTEMPTS, BORGO_MAX_SOCKETS, BORGO_MAX_STREAMS and BORGO_WS_ALLOW_NO_ORIGIN. For an embedder that never calls either and still wants a typo to fail at boot rather than on the first request. |
stable |
Version |
The released version this binary was built from, kept honest by a test that reads the release manifest. | stable |
Serve was provisional in 0.20 only in its shape: returning nothing and calling log.Fatal made it impossible to embed or to exercise from a test. 0.21 added ServeContext beside it rather than changing it, so both are stable and Serve stays the one you want when the process exists to be the server.
Readiness, logs and metrics#
New in 1.1. See deploy for what each is for.
| Symbol | What it is for | Stability |
|---|---|---|
Ready(name string, check func(ctx context.Context) error) |
Registers something the app cannot serve without: GET /readyz answers 503 for as long as check returns an error, panics, or takes more than two seconds. The check runs on every probe, so it has to be a ping and not a query. Call Ready from init or main, before Serve; it panics on an empty name, a nil check, or a name registered twice. |
provisional |
RequestID(r *http.Request) string |
The id of the request: the one in the X-Request-Id response header and in the access log. A call a loader or an action makes on the internal listener carries the id of the page request it belongs to. Empty for a request borgo did not receive itself — a handler called from a test. |
provisional |
Log(r *http.Request) *slog.Logger |
The default slog logger with request_id on every record it writes; the default logger itself when the request has no id. |
provisional |
OnPanic(f func(r *http.Request, v any, stack []byte)) |
Registers a function that is told when a handler panics, in addition to the log line and the 500 borgo writes. There is one hook: a second call replaces the first. It runs on the request's goroutine before the 500 is written; a hook that panics is logged and the 500 is still written. |
provisional |
NewCounter(name, help string) *Counter |
A counter of the app's own, written out after borgo's on /metrics. The name is lower-case letters, digits and underscores; one that starts with borgo_, or is made twice, panics. |
provisional |
Counter |
What NewCounter returns: Inc() counts one, Add(n int64) counts n, and a negative n is ignored. |
provisional |
Responses#
| Symbol | What it is for | Stability |
|---|---|---|
JSON[T any](w, status int, v T) |
Writes v as a JSON response. The type parameter is what borgogen reads to type the route's response for TypeScript. |
stable |
Error(w, status int, v any) |
Writes v as a JSON response the typed bridge never reads: what an error helper that takes its status as a parameter calls, so a refusal does not join the type of every route that can refuse. |
provisional |
WriteJSON(w, status int, v any) |
Deprecated in 1.0: JSON(w, status, v) is the same call with the type visible to borgogen, and Error the one for a refusal. Keeps working, and borgogen keeps reading it, until 2.0. |
deprecated |
Bind[T any](r) (T, error) |
Decodes the request body as JSON into T, capped at 1 MB. Requires Content-Type: application/json — a missing header is rejected like a wrong one. Types the route's request body for TypeScript. |
stable |
BindMax[T any](r, limit int64) (T, error) |
Bind with an explicit byte cap; limit <= 0 disables it. |
stable |
BindValid[T any](r) (T, error) |
Bind, then the form's own judgement: a T with a Validate() error method, on the value or on its pointer, is asked after decoding, and what it returns is the error. For a T without one, BindValid is Bind. borgogen reads it as it reads Bind. |
provisional |
Invalid |
map[string]string, a refusal that names fields: each field mapped to what is wrong with it. An error; BindError and Signup write it as 422 {"error": "some fields are not acceptable", "fields": {...}}. |
provisional |
(Invalid).OrNil() error |
What Validate returns: nil when the map is empty. An empty Invalid returned directly is a non-nil error. |
provisional |
BindError(w, err error) |
Answers a Bind error with the right status: 413 oversized, 415 missing or non-JSON content type, 400 otherwise. An Invalid from BindValid is a 422 {error, fields}, and a Refuse its own status and body. The same for BindMultipart, where 413 also covers the parser's limits (1000 parts, about 18 MiB of text), 415 is a content type that is neither multipart/form-data nor JSON, and 500 is a form type no part can fill, or an upload the server could not write to disk. |
stable |
BindMultipart[T any](r) (T, error) |
Decodes a multipart/form-data body into a struct, capped at 32 MiB: text parts into string, bool, integer, float and []string fields by their json name, files into File, *File or []File. A JSON body is read too, with every File zero: the client sends one when the form holds no file. Types the route's request body with the files as Blob. A field type no part can fill is a 500 on every request, named in the log. |
stable |
BindMultipartMax[T any](r, limit int64) (T, error) |
BindMultipart with an explicit byte cap; limit <= 0 disables it. |
stable |
Uploads{Dir, Types} |
Stores uploaded files in Dir (created 0700) and serves them back. Types lists the sniffed media types accepted; empty accepts any. |
stable |
(*Uploads).Save(f File) (Stored, error) |
Sniffs the bytes, stores the file under a random key, returns what it learned. ErrNoUpload for an empty field, ErrUploadType for a type Types does not list; a failed write leaves nothing. |
stable |
(*Uploads).Serve(w, r, s Stored) |
Answers with the file after the caller's authorization: sniffed type, nosniff, Cache-Control: private, no-cache, a sandboxing CSP, inline only for PNG, JPEG, GIF and WebP. Ranges and conditionals work, and the file is never compressed, whole or in part, so a resumed download counts the bytes it received; an unknown key, or one naming a link, is a 404. |
stable |
(*Uploads).ServePreview(w, r, s Stored) |
Serve for a file a page shows in a frame: a PDF goes out inline, with frame-ancestors 'self' and X-Frame-Options: SAMEORIGIN in place of the sandbox, so a page from the same origin may frame it and no other may. Every other type is served exactly as Serve serves it. |
provisional |
(*Uploads).Remove(key string) error |
Deletes a stored file; a missing one is not an error, a key Save could not have made is. |
stable |
Stored{Key, Name, Type, Size} |
What Save returns and Serve takes: keep it beside the file's owner. Name is the client's, cleaned for display; Type is sniffed. |
stable |
ReadEnv(vars []EnvVar) (map[string]any, error) |
Reads the app's server variables with env.ts's rules and messages, for the generated env/env.gen.go; not written by hand. See the Go half. |
stable |
EnvVar{Name, Type, Optional, Default, Validated} |
One server variable of env.ts, as the generated package declares it. |
stable |
(*Uploads).SaveReader(name string, r io.Reader, max int64) (Stored, error) |
Save for bytes that did not arrive in a form — a file the server fetched or generated — with the same sniffing, Types and random key. Takes at most max bytes, and the limit is not optional: one byte more is ErrUploadTooLarge, and nothing is left behind. |
provisional |
ErrNoUpload, ErrUploadType |
The two refusals of Save a handler answers itself, usually with 400 and 415. |
stable |
ErrUploadTooLarge |
SaveReader's refusal of more bytes than it was told to take, usually a 413. |
provisional |
File |
One uploaded file: Name and ContentType as the client sent them (claims, not evidence), Size, and Open() for the bytes, valid until the handler returns. |
stable |
Cache(w, maxAge time.Duration, staleWhileRevalidate ...time.Duration) |
Marks the response publicly cacheable; downgrades to private if the response already carries Set-Cookie. |
stable |
NoCache(w) |
Marks the response no-store. |
stable |
Cache was provisional until 1.0 because of the variadic third parameter, which is Go's idiom for "I did not want to define an options type" and cannot grow a second option without another one; 1.0 kept the shape and made it stable (finding 3).
Sessions#
| Symbol | What it is for | Stability |
|---|---|---|
SetSession(w, v any, maxAge time.Duration) error |
Stores v JSON-encoded and HMAC-signed in the borgo_session cookie. The expiry is signed too. Errors if the cookie would exceed 4 KB. |
stable |
GetSession[T any](r) (T, bool) |
Verifies signature and expiry and decodes into T. False for missing, tampered, expired — or ambiguous (two valid cookies). |
stable |
ClearSession(w) |
Deletes the session cookie. | stable |
RenewSession[T any](w, r, olderThan, maxAge time.Duration) bool |
Writes the session again, lasting maxAge from now, when the one the request carries was issued more than olderThan ago; reports whether it wrote one. For a session that lasts for as long as it is used; call it from the app's middleware. A session CheckSession refuses is not renewed. |
provisional |
WithSession(r *http.Request, v any) *http.Request |
The request as one made by v: GetSession on it reads v, whatever cookie it carries. For api/middleware.go when it has authenticated a request its own way, a bearer token above all. Nothing is checked and no cookie is written. See a session that did not come in a cookie. New in 1.1. |
provisional |
package borgotest |
Request, As, SetPath, Do and an Answer with Status, JSON, Cookie: a handler called from a test as a page calls it. And borgo-framework/testing: loaderContext, actionContext, refused. See testing your app. New in 1.1. |
provisional |
CheckSession(check func(r *http.Request, s SessionInfo) bool) |
Registers the one check Go runs on every session whose signature and expiry verified, before anything reads it: GetSession, Authed, and the session handed to the render service. false, or a panic (logged), makes the request one without a session; the cookie is not rewritten. Runs at most once per request under Serve. Panics on nil, on a second registration, and after Serve. See revoking sessions. |
stable |
SessionInfo |
What the check sees: IssuedAt time.Time, to the millisecond (the Unix epoch for a session written before 0.30), and Data json.RawMessage, the stored JSON — decode it, do not modify it. |
stable |
ErrNoSessionSecret |
Returned by SetSession when there is no usable SESSION_SECRET — unset, or set to fewer than 32 bytes, which sessionSecret() reports as absent deliberately so that every guard covering the missing case covers the weak key too. In practice only the unset case reaches a running handler: Serve refuses to boot on a short secret. |
stable |
Auth#
| Symbol | What it is for | Stability |
|---|---|---|
Auth[U any] |
Struct wiring an app's user store to ready-made login/logout/register handlers over the session. | stable |
Auth.Lookup func(ctx, username) (U, string, error) |
Required. Returns the user and its stored password hash. Any error reads as invalid credentials. | stable |
Auth.Register func(ctx, username, hash string) (U, error) |
Optional. Without it, RegisterHandler answers 404. Return ErrUserExists for a taken name. |
stable |
Auth.Principal func(u U) any |
Optional, and set it: maps the user to what the session stores and the login and register responses return. Without it the whole user is both, a password hash included. | provisional |
Auth.MaxAge time.Duration |
Session lifetime; default 7 days. | stable |
Auth.Hasher PasswordHasher |
Password hasher; default DefaultHasher(). |
stable |
Auth.Rehash func(ctx, username, hash string) error |
Optional. Stores a new hash for a user whose stored hash is out of date, as judged by the Hasher when it is also a Rehasher. Called after a successful sign-in, with the verified password hashed afresh; an error is logged and the sign-in stands. |
provisional |
Auth.OnEvent func(r *http.Request, e AuthEvent) |
Optional. Told of every sign-in, failed sign-in, refused sign-in, sign-out and new account these handlers see. Runs on the request's goroutine before the response is written; a panic in it is logged and the response is unchanged. | provisional |
AuthEvent{Kind, Username, Client, At} |
What OnEvent is told. Username is what the client sent, cut to 256 bytes and with control characters replaced by spaces — empty for AuthLoginLimited and AuthLogout — and Client is ClientIP's answer for the request. |
provisional |
AuthEventKind |
A string: AuthLogin ("login"), AuthLoginFailed ("login_failed"), AuthLoginLimited ("login_limited"), AuthLogout ("logout"), AuthRegistered ("registered"). |
provisional |
Rehasher |
Interface a PasswordHasher may also satisfy: NeedsRehash(hash string) bool. The default hasher satisfies it, and answers true for a PBKDF2 hash with fewer iterations than it uses today. |
provisional |
(*Auth[U]).LoginHandler |
Verifies credentials, starts a session, responds with the principal. 503 + Retry-After when the hash queue is saturated; 429 + Retry-After for an address that failed BORGO_LOGIN_ATTEMPTS times in a minute, until the minute is over. An attempt is counted when it is let in and given back when the password was right; since 1.1 an IPv6 address is counted by its /64. |
stable |
ClientIP(r *http.Request) string |
The address a request came from, to count or log by: the peer, unless the peer is a proxy named in BORGO_TRUSTED_PROXIES — then the last address in X-Forwarded-For that is not a trusted proxy. Never the header's first entry, which is the client's own claim. |
provisional |
(*Auth[U]).LogoutHandler |
Clears the session cookie, 204. | stable |
(*Auth[U]).RegisterHandler |
Hashes, creates, starts a session, 201. 409 for a taken username. Signup over Credentials alone. |
stable |
Signup[U, S SignupForm](a *Auth[U], register func(ctx, form S, hash string) (U, error)) http.HandlerFunc |
The register handler for a body of the app's shape: any struct embedding Credentials, decoded with Bind and handed to register beside the password's hash. Same answers as RegisterHandler; the typed bridge reads S as the route's request type. |
stable |
Refuse(status int, body any) error |
The error a Signup form's Validate() error, or its register function, returns to answer with that status (400-599, else 400) and JSON body instead of borgo's; what it returns is a *Refusal{Status, Body}, exported with it. A form's Validate runs before the password is hashed. Since 1.1 a Validate that BindValid calls may return it too, and one that returns an Invalid is answered 422 with its fields. |
stable |
SignupForm |
What Signup accepts: a struct embedding Credentials by value. The interface's method is unexported, so embedding is the way to satisfy it; the compiler also admits a pointer, an interface or an embedded *Credentials, and Signup refuses those by name where it is built, since a body of null would leave the promoted method a nil to call. |
stable |
WithHashSlot(w http.ResponseWriter, r *http.Request, hash func()) bool |
Runs hash while holding one of the slots that LoginHandler and Signup do their hashing in, for a handler of your own that hashes or verifies a password: a password change, a confirmation before deleting an account. Reports false when the request was shed — a 503 with Retry-After, already written, once it has queued for five seconds — or the client left before its turn; in both cases, just return. |
stable |
Authed(next http.HandlerFunc) http.HandlerFunc |
Guards an API route: 401 JSON without a valid session. borgogen sees through the wrapper, so the route keeps its types. |
stable |
Credentials |
The {username, password} JSON body the login and register handlers decode. |
stable |
ErrUserExists |
Sentinel for Auth.Register, answered as 409. |
stable |
PasswordHasher |
Interface: Hash(password) (string, error), Verify(password, hash) bool. |
stable |
DefaultHasher() PasswordHasher |
Returns the PBKDF2-SHA256 hasher used when Auth.Hasher is nil. |
stable |
Auth.Principal is provisional because it returns any in a struct that is otherwise generic over U — the one place in the Go API where a type is thrown away. DefaultHasher was a package-level variable of interface type until 0.21, which meant any code in the process could reassign it and silently change hashing for every Auth that did not set Hasher; it is a function now, and to use another algorithm you set Hasher on the Auth you own.
Middleware and request values#
| Symbol | What it is for | Stability |
|---|---|---|
With(r, key string, value any) *http.Request |
Returns r carrying value under key for the handlers behind the middleware that set it. Stays in the Go process. A derived request leaves its parent's values alone. See middleware and authorization. |
stable |
Forward(r, key string, value any) *http.Request |
With, and the value also reaches the render service: middleware.ts, loaders and actions read it in locals. Must encode as JSON, and everything forwarded must fit in 16 KiB encoded; either failure answers 500 rather than rendering without it. |
stable |
Value[T any](r, key string) (T, bool) |
Reads what With or Forward set. False when nothing was set or the value is not a T. |
stable |
Limit(most int, per time.Duration, key func(*http.Request) string) func(http.HandlerFunc) http.HandlerFunc |
Wraps a handler so that one key is answered at most most times in per; past that it gets 429 with Retry-After until the window is over. key says what a request is counted under — ByClient when nil — and a request it returns "" for is not counted. Counts are kept in this process, and each call to Limit keeps its own. Panics unless both numbers are positive. borgogen does not read through it: a route mounted as Limit(...)(h) keeps serving and its types are unknown. |
provisional |
ByClient(r *http.Request) string |
The key Limit counts by when given none: ClientIP's answer, with an IPv6 address reduced to its /64. |
provisional |
UseMiddleware(mw func(http.Handler) http.Handler, matcher []string) |
Registers api/middleware.go's Middleware and Matcher. borgogen generates the call. Panics on nil, on a second registration, after Serve, and on a matcher entry that could never match. |
internal |
Export(name string, h ExportHandler) |
Registers a //borgo:export adapter. borgogen generates the call. |
internal |
ExportHandler |
func(ctx, args []json.RawMessage) (any, error): the adapter borgogen generates for one export. |
internal |
ExportArity(name, want, got), ExportArgument(name, index, err) |
The errors a generated adapter returns for a call that does not fit the function; answered 400. |
internal |
Server-sent events#
| Symbol | What it is for | Stability |
|---|---|---|
SSE(w, r) (*SSEStream, error) |
Prepares the response for SSE (headers, flush, deadlines cleared) and returns the stream. | stable |
SSEStream |
One open SSE response. | stable |
(*SSEStream).Send(event string, data any) error |
Writes one named event with a JSON payload. Rejects newlines in the event name. | stable |
(*SSEStream).Ping() error |
Writes a comment line so proxies do not close an idle stream. | stable |
(*SSEStream).Done() <-chan struct{} |
Closes on client disconnect, server shutdown, or Close. A stream handler must return when it fires. |
stable |
(*SSEStream).Close() |
Ends the stream from the handler's side: fires Done and refuses every later Send and Ping with ErrStreamClosed. Idempotent, safe from any goroutine. For a handler that detached the request context and so has a stream no disconnect or shutdown will ever end. Writes nothing to the client. |
stable |
ErrTooManyStreams |
What SSE returns, having answered 503, when the process already holds BORGO_MAX_STREAMS streams. |
provisional |
ErrStreamClosed |
What Send and Ping return after Close. A stream ended by disconnect or shutdown reports the connection's own error instead — watch Done for those. |
stable |
SSEHub |
Broadcasts events to every connected client. | stable |
NewSSEHub() *SSEHub |
Constructor. | stable |
(*SSEHub).Publish(event string, data any) |
Sends to every subscriber; slow clients skip rather than block the publisher. | stable |
(*SSEHub).ServeHTTP(w, r) |
Streams hub events to one client. Register it as a route handler. | stable |
(*SSEHub).Subscribers() int |
How many clients are connected right now. | stable |
(*SSEHub).Close() |
Ends every stream on the hub and drops its subscribers. Idempotent. | stable |
WebSocket topics#
| Symbol | What it is for | Stability |
|---|---|---|
Push[T any](topic, event string, data T) error |
Publishes to a WebSocket topic, in this process - a subscriber connected to another instance never sees it, unless a FanOut is set, in which case it is handed the event in place of the local sockets: since 0.30 the relay lives beside the handlers and a push is a call. An error names a topic no handshake could hold, a payload over the message limit, or a process with no relay; a topic nobody holds right now is delivered to nobody and is not an error. borgogen records T in the generated event map, typing the browser's subscribe callback. |
stable |
TopicCheck |
func(r *http.Request, topic string) bool: one topic on one request, the session readable with GetSession. |
stable |
CanSubscribe(check TopicCheck) |
The check every topic a socket asks for must pass, once per topic at the handshake. A refused topic closes the socket with 4403 naming it. Registered once, before Serve. Without one, borgo dev admits everything and borgo start refuses everything, each saying so at startup. A check that panics refuses. |
stable |
CanPublish(check TopicCheck) |
The check a browser's publish must pass, per message; without one, publishing follows CanSubscribe - so every socket a topic admits may send any event on it, the ones Push sends included. A refused message is dropped, the socket stays open. |
stable |
Disconnect[T any](match func(session T, topics []string) bool) int |
Closes every socket whose session match accepts — the session its handshake read, decoded into T as GetSession decodes it, beside the topics it holds — and reports how many. A browser's subscribe redials at once and passes CanSubscribe again: call Disconnect after storing a change in who may hold what. A socket with no session, or one that does not decode into T, is never matched. |
provisional |
OnPublish(stamp PublishStamp) |
The one function every message a browser publishes passes through, after CanPublish: handed the socket's request, the topic, the event and the data as sent, it returns the data that is relayed in its place, or false to drop the message. Where the server puts its own word on a browser's event — who sent it, from the session. What it returns must be JSON a message can carry; a stamp that panics drops the message. |
provisional |
PublishStamp |
func(r *http.Request, topic, event string, data json.RawMessage) (json.RawMessage, bool), what OnPublish takes. |
provisional |
Subscribers[T any](topic string) []T |
Who holds a topic now: the session of every socket subscribed to it, as its handshake read it, decoded into T. One entry per socket, in no order — somebody with two tabs is there twice — and none for a socket with no session or one that does not decode. |
provisional |
Realtime() http.Handler |
The relay as a handler, for an app that mounts borgo on a server of its own: mount it at /ws. One per process, configured from the environment; an environment it cannot read answers 500 with the reason. |
stable |
FanOut(send func(topic, event string, data json.RawMessage) error) |
Sets where Push sends an event when this process is one of several: with one set, Push checks the event as it would at delivery, hands it to send with the data as JSON, returns what send returns, and delivers nothing itself. nil removes it. See more than one instance. |
provisional |
Deliver(topic, event string, data json.RawMessage) error |
Gives an event to the sockets this process holds, and to no bus: what the listening end of a FanOut calls with what the bus brought. An error for data that is not JSON, a topic no handshake could hold, or a process with no relay. |
provisional |
push.go declares exactly one exported function for publishing. PushT was folded into it in 0.21 — see finding 2.
Cache invalidation#
| Symbol | What it is for | Stability |
|---|---|---|
Revalidate(path string) error |
Drops, in this process, the cached copy of one page (query variants included; a trailing * drops a prefix). Under borgo start a call into the cache in the same process; in borgo dev, where nothing is cached, it changes nothing. An empty or blank path, or one not starting with /, is an error. |
stable |
RevalidateTag(tag string) error |
Drops, in this process, every cached page whose tags export named the tag, compared without surrounding spaces. An empty or blank tag is an error. |
stable |
Both refuse an empty name. Under borgo start the cache is in the process the call runs in, and the call drops the copies there directly; under borgo dev, where nothing is cached, it changes nothing. See cached pages.
Not exported, but worth knowing#
bindLimit (1 MB), sessionCookie ("borgo_session"), sessionCookieMaxLen (4096), gzipMinBytes (1024), sseWriteTimeout (10 s), the PBKDF2 parameters, hashSlots (max(1, GOMAXPROCS/2) unless BORGO_HASH_SLOTS overrides it) and hashWait (5 s) are all unexported constants and variables. They are behaviour users can observe, so they are covered by api stability as behaviour, but there is no symbol to import.
TypeScript: borgo-framework#
packages/borgo/package.json declares six importable entry points — the root, /internal, /router, /runtime, /refresh-runtime and /testing — plus ./package.json. Only the root is intended for application code, and /testing for an app's tests (testing your app); the others exist because generated code has to import from somewhere, and their names say so.
borgo-framework — values#
| Export | What it is for | Stability |
|---|---|---|
redirect(to: string, status = 303) |
Builds a redirect Response for a loader, an action or middleware.ts. |
stable |
navigate(to: string | URL, options?: { replace?: boolean }): Promise<void> |
Browser only. Goes to a page from code as a clicked link would: props fetched, chunk loaded, history pushed or replaced, nothing reloaded. Where there is no client navigation to take — a page with hydrate = false, a static export, another origin — the browser goes there itself. Throws for a destination that is not http(s). |
provisional |
revalidate(): Promise<void> |
Browser only. Runs the current page's loader again and renders what it returns in place, keeping scroll and the state of what stays mounted; reloads the page where nothing is hydrated. | provisional |
next(init?) |
What middleware.ts returns to let the page through; init.headers are added to its response. |
stable |
rewrite(path, init?) |
What middleware.ts returns to render another page of this app for the request, once, without changing the URL. Refused for the page itself, /api, /__borgo, or a path with a query. |
stable |
subscribe(topic, onEvent, options?) |
Opens a WebSocket channel on a topic, with reconnect and backoff. Returns a Channel. options.onRefused(reason) fires once when the relay refuses the socket — its origin, or a topic CanSubscribe said no to: the one close that will not change on a redial — and the channel is over. options.onOpen({ reconnected }) fires each time the socket joins the topic, with reconnected true on every join after the first: where a page refetches what it missed. |
stable |
Island({ name, props, client }) |
Renders a hydration marker for a component in islands/. client is "load" or "visible". |
stable |
CsrfField() |
Renders the hidden CSRF input a <form method="post"> needs. |
stable |
registerServiceWorker(path = "/sw.js") |
Registers a service worker in production only; no-ops in dev, on the server and where unsupported. | stable |
ApiError |
Thrown by the api client for a non-2xx response. Carries status, body — the response's text, its first 2 kB, not an object — and a route-naming message. json() is the body parsed, or undefined when it is not JSON. fields(), new in 1.1 and provisional, is the fields of a 422 written for a borgo.Invalid, as Record<string, string>, and {} for any other refusal. |
stable |
GoError |
Thrown by a //borgo:export call: exportName, the Go error's text as message, and status — 200 for an error the function returned, 400 for a call that did not fit it, 500 for a contained panic. |
stable |
api(route, options?) |
Browser only. The typed client a loader is handed, for the calls a hydrated page makes itself: same route map, same options, ApiError on anything that is not 2xx. Goes through the proxy with the X-CSRF-Token header on unsafe methods; no retries. Throws on the server, where the context's api is the one to use. |
provisional |
apiFetch(input, init?) |
fetch for browser calls to /api/*, attaching the X-CSRF-Token header on unsafe methods. Identical to fetch otherwise. Loaders and actions do not need it — their api client calls the api's internal listener, where the header check does not run. |
stable |
CSRF_FIELD ("__borgo_csrf") |
The hidden form field name, for a page form action. | stable |
CSRF_HEADER ("X-CSRF-Token") |
The header name, for an unsafe /api/* request. |
stable |
csrfCookieValue(header) |
Reads the CSRF token from a cookie header, treating conflicting duplicates as absent. Promoted from provisional in 0.21 — see finding 4. | stable |
defineEnv(schema, runtimeEnv?) |
Declares the app's typed environment in env.ts: validated before the server binds, typed at the call site, client values allowlisted into the bundle by the BORGO_PUBLIC_ prefix. |
stable |
onClientError(handler: (error: unknown, info: unknown) => void) |
Registers the handler that is told of a failure React meets in the browser on a hydrated page: a page that threw while rendering and was caught by its boundary, an error nothing caught, an error React recovered from. One handler; a second call replaces the first. A handler that throws is ignored. | provisional |
onServerError(handler: (error: unknown, context: { request?: Request }) => void) |
Registers the handler that is told of a failure while a page is rendered on the server: a page or a loader that threw, a stream that failed after its first byte. The log line and the 500 are unchanged. One handler; a handler that throws is ignored. |
provisional |
borgo-framework — types#
| Export | What it is for | Stability |
|---|---|---|
ApiRoutes |
Empty interface the generated .borgo/api-types.d.ts augments with one entry per Go route. The seam of the typed bridge. |
stable |
WsEvents |
Empty interface mapping "topic/event" to a payload type. Filled by borgo.Push calls, or declared by hand for browser-published events. |
stable |
LoaderContext |
{ request, params, api, apiUrl, session, locals, once } handed to a page's loader. once(key, load), new in 1.1 and provisional, gives every loader of the route that asks under one key the same promise: the first to ask starts the work. |
stable |
Session |
The session Go verified, as loaders, actions and middleware.ts receive it. An app types it by augmenting the interface: declare module "borgo-framework" { interface Session { userId: number } }. |
stable |
Locals |
What api/middleware.go forwarded with borgo.Forward, typed the same way. |
stable |
PageMiddleware |
The type of middleware.ts's middleware: (request, { url, params, session, locals }) => next() | rewrite() | Response, or a promise of one. |
stable |
PageMiddlewareContext |
The second argument of a PageMiddleware. |
stable |
MiddlewareResult |
What next() and rewrite() return. |
stable |
ActionContext |
The same shape without once, handed to a page's action. |
stable |
PrerenderContext |
{ api, apiUrl } handed to prerenderPaths during borgo export. |
stable |
Head |
{ title?, meta?, links?, lang? }. New in 1.1: lang, the language tag written on <html> for this page, and links, the <link> elements that relate the page to others (canonical, alternate, prev, next, author, license, help, me) - one that loads something is dropped. Will grow optional fields; growth is additive. |
stable |
HeadContext |
{ layouts }, the second argument of a head function: what the layouts around the page loaded, outermost first, null for a layout without a loader. |
provisional |
HydrateMode |
boolean | "visible". |
stable |
Channel<T> |
{ publish(...), close() } returned by subscribe. |
stable |
SubscribeOptions |
{ onRefused?, onOpen? }, the third argument of subscribe. |
stable |
Env<S> / EnvSchema / EnvSpec / EnvType |
The shapes behind defineEnv: the schema, one variable's spec, the built-in type names, the typed result. |
stable |
IslandProps |
Props of <Island>. |
stable |
ApiClient |
The typed api(...) function's type. |
stable |
ApiOptions<K> |
{ query?, headers?, timeout?, body, params } — body and params become required when the route declares them. |
stable |
ApiResponse<K> / ApiRequest<K> |
Response and request types for a route key. | stable |
ApiRouteKey |
The union of registered route patterns, or string when none are. |
internal |
PageModule |
The shape of a pages/*.tsx module. |
stable |
LayoutModule |
The shape of a _layout.tsx module. |
provisional |
LayoutProps<typeof loader> |
The props of a layout component: children, and what the layout's loader returns. |
provisional |
Route |
A manifest entry: pattern, file, module, layouts, islands flag. | internal |
TopicEvents<T> / TopicEventName<T> / PublishArgs<T> |
Conditional-type machinery behind subscribe's and publish's typing. |
internal |
PageModule and LayoutModule are provisional rather than internal because they describe the page contract users write against — but nothing forces a page to import them, and their field set will grow as the page model does.
borgo-framework/router#
Imported by the generated .borgo/routes.gen.tsx for type Route. Since 0.21 nothing here is reachable from the root entry: filePathToPattern, matchRoute and resolveHead were dropped from it (finding 7) and safeDecode was never on it. The type re-exports below still name the same types the root entry exports.
| Export | What it is for | Stability |
|---|---|---|
safeDecode(s) |
decodeURIComponent that returns the input unchanged on a malformed escape. |
internal |
safeHeadAttrs(meta) |
Filters a head.meta entry down to the attribute pairs safe to render. |
internal |
filePathToPattern, matchRoute, resolveHead |
File path → route pattern, pattern matching with params, and head resolution — shared between the build, the SSR server and the browser runtime. |
internal |
safeLang(lang), makeRouteBoundary(Component, createElement) |
What a head.lang may hold, or null; and the boundary every page is rendered in, built from the app's own React on both sides. |
internal |
safeHeadLink(link), canonicalPath(pathname), loadRoute, guardRoute, splitLayoutData, LAYOUT_DATA |
The head.links filter, the one spelling of a path, and the loader and layout-data plumbing the server and the runtime share. |
internal |
Route, PageModule, LayoutModule, LayoutProps, LoaderContext, ActionContext, PrerenderContext, Head, HeadContext, HydrateMode, Session, Locals |
Type re-exports. | see root entry |
The subpath itself is internal. It exists because generated code needs a stable specifier.
borgo-framework/runtime#
The browser runtime. Imported by the generated client entries (.borgo/client.tsx, .borgo/islands-client.tsx, .borgo/client-routes.gen.ts), never by application code.
| Export | What it is for | Stability |
|---|---|---|
mount({ createElement, hydrateRoot, Component, routes, notFound }) |
Hydrates the page and installs client navigation, form enhancement, prefetching, scroll restoration and (in dev) the fast-refresh channel. | internal |
mountIslands({ createElement, hydrateRoot, islands }) |
Hydrates <Island> markers on a page that ships no page bundle. |
internal |
redirectUrl(raw) |
Parses a redirect target, rejecting anything that is not http:/https:. |
internal |
asProps(value) |
Coerces an untrusted loader payload to a props object. | internal |
propsPathEnabled(), devUpdatePlan(files, current), actionOutcome(res), tooLargeDetail(res) |
Whether the ?__borgo=props path was compiled in; what a dev update does to the page on screen; how an action response is classified (action, raw, too-large, unknown); the detail text of a 413. |
internal |
ClientPageModule, ClientRoute, MountOptions, MountIslandsOptions, ActionOutcome |
Types of the above. ClientRoute appears in generated code. |
internal |
borgo-framework/internal#
Everything the generated client entries need and nothing an application should write by hand. The name is the contract: this subpath carries no stability promise and may change in any release.
| Export | What it is for | Stability |
|---|---|---|
CSRF_COOKIE ("borgo_csrf") |
The double-submit cookie's name, for the framework's own modules. Moved here from the root entry in 1.0: the names of borgo's two cookies are a wire contract, written down below, not symbols an app imports; an app reads the token with csrfCookieValue. |
internal |
browserEnv() |
The schema-less proxy the generated client shim of env.ts is built on. Moved here from the root entry in 1.0; the import the shim writes moved with it. |
internal |
registerNavigator(navigator), clientNavigator() |
How the mounted runtime hands navigate() and revalidate() its own navigation. |
internal |
setClientErrorHandler(handler), reportClientError(error, info), setServerErrorHandler(handler), reportServerError(error, context?) |
What onClientError and onServerError set, and how the runtime and the render service reach it. |
internal |
registerCsrf(react: CsrfReact | null) |
Installs the React functions (createElement, createContext, useContext) the CSRF context is built from; null clears the registration. The token itself travels through withCsrf, not through this call. |
internal |
registerIslands(components, createElement) |
Registers the island components a hydrate=false page mounts, plus the app's own createElement — React is injected rather than imported so the framework never bundles a second copy. |
internal |
withCsrf(element, token) |
Wraps a tree in the CSRF context CsrfField reads. |
internal |
csrfRuntime(), islandRegistry() |
The registries themselves, read by the server and the runtime across module boundaries. | internal |
unsafeMethod(method) |
Whether a method is state-changing, and so subject to the CSRF checks. The safe set is GET, HEAD, OPTIONS and TRACE, read by apiFetch and by the render service's form-action check; the Go front's /api check spells the same four. |
internal |
CsrfReact |
Type of the React functions registerCsrf takes. |
internal |
callExport<T>(name, args) |
What the generated .borgo/go.ts calls: a POST to /__borgo/export/<name> on the internal listener with this boot's key. Throws outside the render service. |
internal |
borgo-framework/refresh-runtime#
| Export | What it is for | Stability |
|---|---|---|
default |
Re-export of react-refresh/runtime, so the generated dev entry resolves it through borgo wherever the package manager put it. |
internal |
borgo-framework/package.json#
Exported so borgo doctor can read the installed framework version. internal.
Not exported at all#
makeApiClient (src/api.ts) and everything in build.ts, dev.ts, server.ts's internals, util.ts, compress.ts, doctor.ts, deploy.ts, pwa.ts, export.ts, overlay.ts and colors.ts are private: those modules are not in exports, so they are unreachable from an app. This is correct and should stay that way.
create-borgo#
Published as a package with a single bin. It exposes no importable API — src/cli.ts is an executable, and packages/create-borgo/package.json declares no exports. stable as a command, no API surface.
Environment variables#
Read at runtime unless noted. Defaults in parentheses.
Both halves#
| Variable | Read by | What it does | Stability |
|---|---|---|---|
PORT (3000) |
Go, which binds it; the CLI, which resolves the topology | The public port, and the only one. | stable |
API_PORT (3501) |
Go, which binds it on 127.0.0.1 alone when a render service runs (borgo start, borgo dev) and, in an api-only app where it is the public port, on every interface or on the one BORGO_HOST names; the render service, to dial it |
The API's internal listener, for loaders and form actions. The browser never reaches it — /api/* on the public port is the same mux in the same process. A value that is not a port number (0-65535, digits only) is refused before the Go server binds. |
stable |
SESSION_SECRET |
Go | HMAC key for signed-cookie sessions. At least 32 bytes. Missing is logged at the first use of a session and fails session routes per request; shorter than 32 bytes is fatal at startup — see sessions. | stable |
SESSION_SECRET_PREVIOUS |
Go | The keys that signed before SESSION_SECRET, comma separated. A session one of them signed is still read; none of them ever signs. A key shorter than 32 bytes refuses the boot, naming its position in the list. See rotating the key. |
provisional |
SESSION_SECURE |
Go and the render service | Adds Secure to the session and CSRF cookies, and Strict-Transport-Security to every response. The grammar is exactly Go's strconv.ParseBool, case-sensitive: 1, t, T, true, TRUE, True mean on; 0, f, F, false, FALSE, False mean off; unset means off. Both halves read that alphabet and refuse anything else at startup — yes, on, Yes included — rather than reading it as "not secure". The same grammar governs every boolean switch below (BORGO_CSRF, BORGO_SECURITY_HEADERS, BORGO_METRICS, BORGO_WS_ALLOW_NO_ORIGIN). |
stable |
NO_COLOR |
Go and the render service | Any value disables ANSI colour. | stable |
BORGO_MAX_BODY (33554432) |
Both, each for what it reads | Largest request body either half reads, in bytes, counted as the bytes arrive rather than taken from a header — so a chunked body is bounded like any other, and one that lies about its length is bounded by the smaller of what it declares and what it sends. The front applies it to /api/*, the render service to a form action. 0 means no limit. Refused at boot if it is not a whole number. |
stable |
BORGO_CSRF |
Both, each for its own half | 0 disables both CSRF checks, 1 forces them in dev. Unsafe /api/* requests are checked by the front, form actions by the render service, against the same cookie and the same rejection table. |
stable |
BORGO_SECURITY_HEADERS |
Both | 0 drops the security headers and the CSP. Each half applies them to what it authors, and adds only what the other left empty. |
stable |
BORGO_CSP |
Both | 0 drops the CSP alone and 1 keeps borgo's own; any other value replaces the policy, with {nonce} substituted per render, except a single bare word, which is refused at boot as a possible mistyped switch. The nonced policy is the render service's, since only it knows the nonce; the front applies the same policy without one to what it writes itself. |
stable |
Render service only#
| Variable | What it does | Stability |
|---|---|---|
API_URL (http://127.0.0.1:$API_PORT) |
Where the render service reaches the api - written as 127.0.0.1, since the internal listener is bound to that address and a resolver preferring ::1 for localhost would be refused. |
stable |
BORGO_RENDER_PORT (a free port, picked at boot) |
The loopback port the render service binds. Unset, borgo start and borgo dev pick a free one and set it on both halves from one place, so two apps on one machine never meet on it. Set, it is used as named, and a port that already answers on 127.0.0.1 refuses the boot: on Windows a second process binds a port another one listens on without an error, and takes its traffic. |
stable |
BORGO_INTERNAL_KEY |
The per-boot key that authorises the front's requests to the render service, at least 32 bytes. Normally you never set it: the CLI mints 32 random bytes per boot and hands the same value to both halves. A value shorter than the floor is announced and replaced; a render service that has no usable key refuses to boot, because a loopback listener without one is a listener anyone on the box can drive. | stable |
BUN_CONFIG_MAX_HTTP_REQUESTS (16384 under borgo dev and borgo start; 256, bun's default, otherwise) |
How many outbound calls the render service may have in flight — in practice, loader and action calls to the api. Read by bun at process start and unraisable afterwards. Event streams and websockets are the front's own inbound sockets and are not drawn from this pool. | stable |
BORGO_METRICS was METRICS before 0.21. The old name is not honoured, and not honouring it is the point: a bare METRICS is the most collidable variable borgo ever read, and an alias kept for compatibility would keep the collision alive.
BUN_CONFIG_MAX_HTTP_REQUESTS is bun's, not borgo's, but borgo is why you would set it. A process cannot raise it for itself once bun has booted, so borgo start re-execs itself with 16384 when nothing set it - or with NODE_ENV=production when that is unset - and borgo dev sets it, as do the two borgo deploy init targets that launch the app — the systemd unit and the compose file. The caddy and nginx targets are reverse-proxy configs and set no environment. Setting it yourself is still honoured: start keeps the value, and runs in one process rather than two when NODE_ENV is set too.
The front (Go) only#
| Variable | What it does | Stability |
|---|---|---|
BORGO_RENDER_URL |
The render service the front forwards pages to. Setting it is what makes the binary a front: there is no flag. Unset, the binary is an api alone on its single listener, which is what an app embedding borgo without pages wants. borgo start and borgo dev set it to the loopback render port. |
stable |
BORGO_RENDER_TIMEOUT (30s) |
How long the front waits for the render service's response headers before answering 504. The body is then unbounded, so a streaming document and a websocket are not cut. | stable |
BORGO_TRUSTED_PROXIES (loopback and the private ranges) |
CIDRs or addresses whose X-Forwarded-For and X-Forwarded-Proto are believed. From anyone else those headers are the client's own claims and are rebuilt from the connection. Unset it trusts 127.0.0.0/8, ::1/128, 10/8, 172.16/12, 192.168/16 and fc00::/7, which is what makes the generated compose and reverse-proxy recipes work unconfigured — and it means that on a shared private network (a pod network, an office LAN) any peer that can reach the port can forge the client address in your logs. none trusts nobody; a list of your own proxies is better than both. A malformed entry is refused at boot naming the variable. |
stable |
BORGO_METRICS |
1 exposes /metrics on the public port, in Prometheus text format. |
stable |
BORGO_METRICS_TOKEN |
With it set, /metrics answers a request carrying Authorization: Bearer <token> and answers 404 to every other request. Unset, /metrics answers a request that reached the port itself and answers 404 to one that came through a proxy: any request from a peer BORGO_TRUSTED_PROXIES names when that is set, and, when it is unset, one from a loopback or private peer carrying a header a proxy adds. Read on each request; no value is refused. |
provisional |
BORGO_HOST |
The address the public port listens on: an IP address, 127.0.0.1 for this machine alone. Unset, every interface. A value that is not an IP address — a host name included — refuses the boot. The internal listener is on 127.0.0.1 either way. |
provisional |
BORGO_ACCESS_LOG |
1/true writes one record per request on the public port when it ends: id, method, path without the query, route pattern, status, bytes, duration, client address. The boolean grammar above; anything else refuses the boot. |
provisional |
BORGO_LOG_FORMAT (text) |
json makes every line the Go process writes through log and slog a JSON object on stderr. Anything but json and text refuses the boot. Like the access log, it applies to an api served alone as it does to the front. |
provisional |
BORGO_HSTS |
Unset, Strict-Transport-Security follows SESSION_SECURE. 0/false never sends it, 1/true sends max-age=31536000 whatever SESSION_SECURE says, and the header's own value — max-age=<seconds>, then ; includeSubDomains and ; preload if wanted — is sent as written. Anything else refuses the boot. |
provisional |
BORGO_PERMISSIONS_POLICY |
Sent as the Permissions-Policy header on every response that does not carry one. Unset, no such header. A value with a control character refuses the boot. |
provisional |
BORGO_MAX_INFLIGHT |
/api/* requests served at once on the public port; in an api served alone, every request but /ws, /healthz and /readyz. Past it a request is answered 503 with Retry-After: 1 at once. 0 or unset means no limit; a value that is not a whole number refuses the boot. An event stream gives its place back. |
provisional |
BORGO_HANDLER_TIMEOUT |
How long an /api/* handler has, as a Go duration. When it passes, the request's context is cancelled, and a handler that returns having written nothing is answered 503. 0 or unset means no limit. |
provisional |
BORGO_SHUTDOWN_DELAY (0) |
How long the process goes on serving after a stop signal, with /readyz already answering 503, before the listeners close. A Go duration. |
provisional |
BORGO_CACHE_DIR (.borgo/cache/html) |
Where cached pages persist across restarts, keyed to the build that rendered them. | stable |
BORGO_WS_ALLOW_NO_ORIGIN |
1/true admits websocket clients sending no Origin. Browsers always send one, so this exists for non-browser clients — and it admits every other originless caller too. Read by Go since 0.30, where /ws is answered; the grammar is the boolean one above, and anything else refuses the boot. |
stable |
BORGO_READ_HEADER_TIMEOUT (5s) |
Cap on reading request headers. | stable |
BORGO_IDLE_TIMEOUT (2m) |
Idle keep-alive reclaim, on both listeners. | stable |
BORGO_READ_TIMEOUT (60s on the public port) |
How long a request body may go without progress. Every read of the body moves the deadline forward, so an upload that keeps arriving is never cut and one that goes silent is. 0 turns it off; an api served alone defaults to 0. |
stable |
BORGO_WRITE_TIMEOUT (60s on the public port) |
How long a response may go without a write. Every write moves the deadline forward, so a streaming render or a large file going to a slow link is never cut, and a client that stops reading is. An event stream clears it at its first byte and keeps its own: SSE bounds each of its writes at 10 seconds. 0 turns it off; an api served alone defaults to 0. |
stable |
BORGO_SHUTDOWN_TIMEOUT (10s) |
Grace period for in-flight requests; 0 waits indefinitely. |
stable |
BORGO_MAX_SOCKETS (10000) |
WebSocket connections the relay holds at once. Past it a handshake is answered 503 with Retry-After, before CanSubscribe is asked. 0 means no limit; a value that is not a whole number is refused by CheckEnv. |
provisional |
BORGO_MAX_STREAMS (10000) |
Event streams borgo.SSE holds at once. Past it SSE answers 503 with Retry-After and returns ErrTooManyStreams. 0 means no limit. |
provisional |
BORGO_LOGIN_ATTEMPTS (10) |
Failed sign-ins LoginHandler takes from one address in a minute before answering 429. 0 turns the limit off, for an app that counts its own. A value that is not a whole number, or is negative, is refused by CheckEnv. |
provisional |
BORGO_HASH_SLOTS (max(1, GOMAXPROCS/2)) |
Password hashes that may run at once. A value that is not a positive integer is refused by CheckEnv, and so by Serve and ServeContext. |
stable |
The five BORGO_*_TIMEOUT entries of 1.0, and BORGO_HANDLER_TIMEOUT and BORGO_SHUTDOWN_DELAY beside them, are Go duration strings; BORGO_HASH_SLOTS is a positive integer. A malformed duration or a non-positive slot count stops the boot before the startup banner, as an error ServeContext returns and Serve exits on — never a panic, so a program that embeds the api keeps its process and can act on the refusal. The slot count is read while the package initialises, before main: there it can only fall back to the default cap and log, and CheckEnv is where it becomes a value.
Where
BORGO_FRONT_READ_TIMEOUTwent. It was the Bun front's socket deadline, and it neededFRONTin the name because one environment reached both halves and Go readsBORGO_READ_TIMEOUTandBORGO_IDLE_TIMEOUTas durations while bun read whole seconds —=2mconfigured one half and silently left the other on its default. The public port is Go's now, so the deadlines a client meets are the Go ones above, in Go's grammar, refused loudly when malformed. The render service has no deadline knob at all: its only client is the front, on loopback, and a deadline there would have bounded the response write too — which is what the keep-warm mechanism existed to work around, and it is deleted with it. Neither old name is honoured as an alias.
Build, dev loop and internal#
| Variable | What it does | Stability |
|---|---|---|
BORGO_TAILWIND |
Set to 1 by --tailwind for child processes. Use the flag, not the variable. |
internal |
BORGO_SOURCEMAP |
1, and only 1, makes a production build write a source map per chunk into dist/sourcemaps/, named <chunk as served>.map, as borgo build --sourcemap does. Nothing served names or contains one. A build that asks for none empties that directory. Read by the build alone; not in dev. |
provisional |
BORGO_PARENT_PID |
How the CLI tells a child process whose death to exit with. The Go server refuses a value that is not a positive integer, and refuses to start at all if that process is already gone — silently running unwatched is the orphaned api this variable exists to prevent. | internal |
BORGO_SUPERVISOR_PID |
Set by borgo start on the copy of itself it re-execs to raise BUN_CONFIG_MAX_HTTP_REQUESTS or set NODE_ENV; the child polls it and exits when the supervisor does. |
internal |
BORGO_RELOAD |
Marks a restart so the banner prints the short form. | internal |
BORGO_API_LOOPBACK |
Set to 1 by borgo export on the api it runs for the exported pages' loaders: an api alone then listens on 127.0.0.1 instead of every interface. |
internal |
BORGO_CHANGED |
Carries the changed file set into the dev fallback server — newline-separated, because a path may contain a comma or a space but not a newline. Two saves inside one debounce window announce both; carrying only the first meant the browser, which ignores an update naming a page other than the one on screen, could apply nothing at all. | internal |
BORGO_STATIC |
Set to 1 by borgo export for the build it drives, and substituted into the client bundle as a define rather than read at runtime — it is what compiles the ?__borgo=props navigation path out of an exported site, where there is no server to ask for props. Not something to set by hand. |
internal |
BORGO_DEV |
Set by the dev loop for serve-entry.ts. |
internal |
BORGO_DEBUG |
1 is the --debug flag for a build that has no command line. Read by the build alone, and only 1 — it is not one of the boolean switches above. |
internal |
BORGO_FORCE_PROMPT |
Test hook: forces create-borgo's interactive path. |
internal |
BORGO_SPAWN_TIMEOUT_MS |
Test hook: overrides the deadlines create-borgo gives the tools it spawns. |
internal |
NODE_ENV |
A build-time define in client bundles; on the server, React picks its production or development build by it when first loaded, so borgo start sets production when it is unset, re-execing to do it. |
internal |
DB_PATH, which appears in the deploy samples and the example app, is the application's variable, not borgo's.
CLI#
borgo#
Run from an app root — the directory holding pages/.
| Command | What it does | Stability |
|---|---|---|
borgo dev |
Starts both servers, watches, fast-refreshes. | stable |
borgo build |
Runs borgogen, builds client assets into public/assets/, compiles the Go binary into dist/. |
stable |
borgo start |
Runs from build output, supervising both processes. Rebuilds automatically if public/assets holds a dev build. Re-execs itself once with BUN_CONFIG_MAX_HTTP_REQUESTS=16384 and NODE_ENV=production when either is unset, keeping a value that was given — the supervisor forwards signals and exits with the child's code. |
stable |
borgo export |
Static site into dist/site/. |
stable |
borgo deploy init <caddy|nginx|systemd|compose> |
Writes a deploy config. | stable |
borgo pwa init |
Writes public/manifest.webmanifest and a service worker. |
stable |
borgo doctor |
Runs sixteen checks over the toolchain (bun, a bun shim shadowing it, a second bun in ~/.bun/bin that is not the one on PATH, an engines.bun range in package.json borgo cannot read as a minimum, go, node, docker), the machine (both ports, disk space) and the project (api binary, generated types, node_modules, app deps, write access, playwright browsers). Checks that do not apply return nothing; informational ones (node, docker, the shim, second-bun and engines.bun notes) report without affecting the exit code. |
stable |
borgo / borgo --help / -h / --version / -v |
Banner and usage; exits 0. An unknown command exits 1. | stable |
| Flag | Applies to | What it does | Stability |
|---|---|---|---|
--tailwind |
any command (parsed globally) | Hands the CSS pipeline to Tailwind (the @tailwindcss/postcss plugin); sets BORGO_TAILWIND=1 for children. |
stable |
--front-only |
start |
Retired in 0.30 and refused with an explanation: the Go binary is the front now, so running the Bun half alone would bind loopback with nothing in front of it. A two-host split is not wired yet. | removed |
--force |
pwa init, deploy init |
Overwrites existing files. | stable |
--sourcemap |
build |
Writes a source map per chunk into dist/sourcemaps/, as BORGO_SOURCEMAP=1 does; nothing served names one. |
provisional |
--debug |
dev, build, start, export, doctor |
Prints the stack and the cause chain behind a build failure instead of the one-line report. BORGO_DEBUG=1 does the same for a build with no command line, such as the dev loop's own rebuilds. |
stable |
An argument a command does not know — a stray positional or an unknown --option — is refused before the command runs, with usage; a build that ignored it would exit 0 having done something other than what was asked.
The exit codes are part of the contract: build exits 1 if borgogen or go build fails, start exits with the api's own code if the api dies, doctor and export exit with their own status.
create-borgo#
| Form | What it does | Stability |
|---|---|---|
bunx create-borgo@latest <name> |
Scaffolds a new app. In an interactive terminal it asks seven questions — template, Tailwind, linter, git, docker, vscode, and whether to install dependencies and start the dev server; anywhere else (CI, piped stdin) it takes the defaults without blocking. | stable |
--template <base|minimal|full>, -t, --template=<x> |
Picks a template; default base. |
stable |
--tailwind / --no-tailwind |
Wires Tailwind, or declines without prompting. Default off. | stable |
--linter <biome|eslint|none>, --linter=<x> / --no-linter |
Writes the chosen linter's config and the lint / format scripts. Default none. |
stable |
--git / --no-git |
git init plus an initial commit. Default on. |
stable |
--docker / --no-docker |
Keeps Dockerfile, docker-compose.yml and .dockerignore. Default on. |
stable |
--vscode / --no-vscode |
Writes .vscode/extensions.json and settings.json. Default on. |
stable |
--install / --no-install |
Runs bun install and go mod tidy after scaffolding. Default on in a terminal, off everywhere else, so a scaffold step in CI exits on its own. --no-install also settles --start: without dependencies the run prints the manual steps and exits. |
stable |
--start / --no-start |
Installs, then hands over to the dev server. Same default rule as --install; --start in a script is honoured, because it is a request to block on a server. |
stable |
--yes / -y |
Takes every default without opening stdin — the terminal's defaults when run in one, so -y in a terminal installs and starts too. |
stable |
--help / -h |
Usage. | stable |
Every on/off option has a --no- twin (--no-tailwind, --no-git, --no-docker, --no-vscode, --no-install, --no-start). --template and --linter take a value instead, and only --linter has a --no- form (--no-linter means none). Install and start are one question at the prompt because they are one intent, and two flags because a script that wants the dependencies without a server that never exits has no other way to say so.
An unknown argument is an error, not a silently ignored token.
borgogen#
Invoked as go tool borgogen, wired through the app's go.mod tool directive. It takes no flags and reads the working directory. stable as a command; its output is a contract covered in api stability.
The names it writes into .borgo/api-types.d.ts are part of that output. A Go struct becomes an interface of the same name as encoding/json writes it; where it is read differently — every struct handed to Bind, since the decoder makes every property optional and nullable — it gets a second declaration under <Name>$Request, and where a pointer-receiver marshaler makes the written shape depend on position, a <Name>$Addressable. $ cannot occur in a Go identifier, so neither suffix can collide with a type of yours. A Go type whose name is a TypeScript reserved word, or one of the two generics the file uses (Array, Record), is renamed with its package as a prefix — type null struct{…} in api comes out ApiNull — rather than emitted as a declaration that would break the whole file. The rules are in the typed bridge.
File conventions#
These are as much a public API as any function: an app depends on them, and changing one breaks builds.
Directory layout#
| Path | Meaning | Stability |
|---|---|---|
pages/**/*.tsx |
Routes. index.tsx → /, [id].tsx → :id. Static segments beat dynamic ones. |
stable |
pages/**/_layout.tsx |
Layout for its directory and below; nests outermost-first. Must default-export a component taking { children }. |
stable |
pages/_404.tsx, pages/_500.tsx |
Not-found and error pages. | stable |
pages/**/_*.tsx |
Any file whose basename starts with _ is special and is not routed. |
stable |
islands/*.tsx |
Island components, default-exported, referenced by <Island name="Counter" />. |
stable |
api/*.go |
The Go API package. api/borgo.gen.go is generated; *_test.go is ignored by borgogen. |
stable |
api/middleware.go |
By convention, where func Middleware(http.Handler) http.Handler and an optional var Matcher []string live; borgogen finds them anywhere in package api. See middleware and authorization. |
stable |
middleware.ts |
The pages' middleware, at the app root: exports middleware and an optional matcher. A malformed one refuses the boot; a matcher naming /api or /__borgo refuses the build too. |
stable |
.borgo/go.ts |
Generated when the api package declares a //borgo:export: export const go = { ... }, one typed stub per export; removed when there are none. |
stable |
env.ts |
The app's typed environment, when it declares one: checked at boot, client values shipped by the build. | stable |
env/env.gen.go |
Generated from env.ts by borgo build and borgo dev when it declares a server variable: package env, a typed Server, Load() and Must(). Committed; removed when no server variable is left. See the Go half. |
stable |
public/ |
Served as-is. public/assets/ is build output. |
stable |
index.html |
The SSR shell. | stable |
style.scss |
Compiled to public/assets/style.css when present. |
stable |
style.css |
Tailwind entry, used only with --tailwind. |
stable |
.borgo/ |
Generated: api-types.d.ts, routes.gen.tsx, client-routes.gen.ts, islands.gen.ts, client.tsx, islands-client.tsx, refresh.ts (dev only), build-mode, build-incomplete (present only while a build is running, or after one that died), build-output.json, middleware.json, the build.lock and dev.lock files, and the dev api binary. Everything but api-types.d.ts is gitignored by the templates. |
internal |
dist/ |
borgo build output (the Go binary), borgo export output (dist/site/), and the source maps of a build that asked for them (dist/sourcemaps/). |
stable |
Page module exports#
| Export | Meaning | Stability |
|---|---|---|
default |
The React component. Required — a page without one fails the build with a named error. | stable |
loader(ctx) |
Runs on the server; returns props or a Response. Stripped from client bundles. |
stable |
action(ctx) |
Runs on a POST; returns props, actionData or a Response. Stripped from client bundles. |
stable |
head |
Head object or (props, { layouts }) => Head. The second argument is new in 1.1. |
stable |
ErrorBoundary |
Component taking { error, reset }, shown in place of the page when rendering it throws in the browser. The layouts stay. Without one, a plain notice with a reload button. |
provisional |
hydrate |
true, false or "visible". Must be a literal — it is read from the source text without executing the module. |
stable |
prerender |
true opts a loader page into static export. |
stable |
prerenderPaths(ctx) |
Lists param sets for a dynamic route during export. | stable |
revalidate |
Seconds a shared cached copy stays fresh - rendered with no session, and never for a page middleware.ts can reach, or "manual" for invalidation-only. Production only; a malformed value is named in the log and the page served fresh. |
stable |
tags |
Array of tag names borgo.RevalidateTag drops the page by. Read only beside revalidate. |
stable |
Go directives#
| Directive | Meaning | Stability |
|---|---|---|
//borgo:route METHOD /path |
Mounts the following package-level handler. Must be the function's doc comment, no space after //, and the handler must be func(http.ResponseWriter, *http.Request) with no type parameters. |
stable |
//borgo:type <GoType> <TSType> |
Overrides the TypeScript type generated for a named Go type. May sit anywhere in the api package. |
stable |
//borgo:type <GoType>@<file.go>:<line> <TSType> |
The same, aimed at one specific declaration — for when a bare name is ambiguous. | stable |
//borgo:export |
Makes the following package-level function callable from the render service as go.<name> in .borgo/go.ts. It must be exported, not generic, not variadic, take a context.Context first, return (T, error) or error, and use types that cross as JSON; borgogen refuses anything else with the file and line. |
stable |
//borgo:topic <pattern> |
Names the shape of a computed topic on the borgo.Push call below it, or on the line the call starts on, one call per directive: literal text and {name} placeholders, no /, , or whitespace, at most 128 characters of literal text. The event lands in WsEvents as a template-literal key the client narrows on. On a literal topic, on no call, claimed twice, with a computed event, malformed, or colliding with another key of the same event on a different payload: the run fails naming the line. |
stable |
A comment that looks like a route directive but is not attached to a handler produces a warning rather than silence — as does a directive in a file the build excludes.
<GoType> takes three spellings, and each resolves to at most one type:
pkgpath.Namefor an imported type (gorm.io/gorm.DeletedAt). Checked against what theapipackage imports; a path it does not import is left alone, since the type may still be reached through a helper package.- a bare
Namefor a type theapipackage declares, or a predeclared one. It resolves to the package-level type if there is one, and to the sole function-local one if there is not. Name@file.go:lineto name one declaration outright. This form picks out a function-local type of theapipackage, so pairing it with a dotted imported name is an error.
A bare name used to apply to every type of that name, so a directive meant for a package-level type silently rewrote each function-local type resp struct{…} that shared it. When a bare name is genuinely ambiguous borgogen now fails the run, listing every candidate and the spelling that settles it:
ambig.go:13:1: //borgo:type stamp is ambiguous: this api package declares 2 types
named stamp, at ambig.go:17, ambig.go:25. Name the one you mean as stamp@ambig.go:17
Failing is the point: a directive that is well formed and still does nothing reads as applied, and leaves you looking at the type it was meant to replace. For the same reason the run also fails on a malformed directive, on one naming a Go type the api package cannot refer to, and on two directives mapping one type to different TypeScript.
Markers, params and headers the runtime owns#
| Name | Where | Meaning | Stability |
|---|---|---|---|
data-borgo-island, data-borgo-props, data-borgo-client |
DOM | Island hydration markers. | internal |
data-borgo-visible |
DOM | Hydration trigger element for hydrate = "visible". |
stable |
data-borgo-head |
DOM | Meta tags the client runtime owns and replaces. | internal |
data-borgo-native |
<form> |
Opts a form out of enhanced submission. | stable |
?__borgo=props |
URL | Asks a page for its loader props as JSON. The answer names the build that made it, and a tab running another build loads the page whole. | internal |
data-borgo-error |
DOM | On the <main role="alert"> of the default notice shown for a page that threw. |
internal |
#borgo-announcer |
DOM | The visually hidden aria-live element the runtime writes the title into after a client navigation. |
internal |
X-Borgo-Action, X-Borgo |
HTTP | Action request marker, and the response discriminator (action / raw). |
internal |
X-Borgo-Cache |
HTTP | How a cached page answered: miss, hit, stale or bypass. Diagnostic — read it, do not build on it. |
stable |
X-CSRF-Token |
HTTP | The double-submit token on an unsafe /api/* request. apiFetch attaches it. |
stable |
X-Request-Id |
HTTP | On every response from the public port, and on the request as handlers and the render service see it. An inbound one is kept only from a peer in BORGO_TRUSTED_PROXIES, and only if it is at most 128 characters of letters, digits, -, _, . and :. |
provisional |
borgo_session, borgo_csrf |
Cookies | The two cookies borgo owns. | stable |
/healthz, /readyz, /metrics, /ws, /api/*, /assets/*, /__borgo/* |
URL | Reserved paths. An app route must not claim them. /healthz and /readyz are the ones an app may claim, and only in an api served alone: behind the front, the front answers them before any route. /readyz is new in 1.1. |
stable |
Findings#
The rest of this page is the audit, not the reference: what the surface got wrong, what it costs to fix, and what was decided. Entries marked landed in 0.21 are done and the reference above already reflects them. The ones that were still open were decided in 1.0, and each says how; no finding here awaits a decision any more.
Duplicated APIs#
1. JSON[T] and WriteJSON — two ways to write a JSON response.
JSON is a one-line delegation to WriteJSON. borgogen reads the response type from both. WriteJSON is also the framework's own writer (used by BindError, Authed, every Auth handler), so it cannot simply vanish.
Disposition taken in 1.0: WriteJSON is deprecated, and the framework's own writer is unexported. WriteJSON carries a Deprecated: comment naming JSON and Error, which editors and staticcheck show; it keeps working, and borgogen keeps reading it, until 2.0 — the first use of the deprecation policy. The docs, the templates and the example no longer call it. The original recommendation: deprecate WriteJSON as public, keep it internal. JSON(w, status, v) with v of interface type infers exactly what WriteJSON did, so the public replacement is a mechanical rename. Documentation should stop mentioning WriteJSON first.
Migration cost: low. A sed in application code; borgogen keeps recognising both through the deprecation window. Affects every app that followed an older tutorial, which is most of them — so this needs a full minor's warning.
2. Push and PushT — same call, one with a visible type parameter. — landed in 0.21
PushT[T] was Push with T exposed to static analysis, delegating straight to it: the same split as JSON/WriteJSON, with the opposite naming convention (see naming, below).
Disposition taken: Push became generic and PushT was removed — no deprecation window, since the alias existed only to carry the type parameter that Push now has. Push[T any](topic, event string, data T) error compiles unchanged at almost every existing call site, because Go infers T from the argument; a site passing an any-typed value still types as T = any.
Migration: rename PushT to Push. The one shape Go cannot infer is an untyped nil — write Push[any](topic, event, nil). Calls that used to type as any may now type precisely, which adds information to the browser: an improvement, and a visible diff in generated files.
3. Cache and NoCache — not actually duplicates. Keep both.
It is tempting to collapse them into Cache(w, 0), and it would be wrong: Cache(w, 0) emits public, max-age=0, which is cacheable-with-revalidation, while NoCache emits no-store, which forbids storage entirely. On a personalized page the difference is a data leak.
Disposition taken in 1.0: both stay as they are, and Cache is stable with its variadic tail. A second name for the two-argument form would be one more thing to learn for no call it makes possible, and an options struct is a break: neither is worth it.
Migration cost: zero (documentation only). Replacing the variadic with an options struct would be a breaking change; defer to 2.0 or add CacheStale(w, maxAge, swr) additively.
4. cookieValue and csrfCookieValue — plus a third parser in util.ts. — landed in 0.21
cookieValue(header, name) is a generic cookie reader exported from the package root and referenced by nothing — not by application code, not by the framework, not by tests. csrfCookieValue(header) is the one that is actually used, and it is deliberately different: conflicting duplicate cookies read as absent, matching the Go side's treatment of ambiguous session cookies. hasCookie(header, name) in util.ts parses the same string a third way (internal, not exported).
Disposition taken: cookieValue was removed; csrfCookieValue is documented and promoted to stable. cookieValue's duplicate-tolerant behaviour is a footgun next to its neighbour. csrfCookieValue earned the promotion because an app doing hand-rolled fetch POSTs genuinely needs the token and <CsrfField /> only covers <form>s.
Migration cost: effectively zero for removal — the symbol is undocumented and unused. Promoting csrfCookieValue is documentation.
5. Bind and BindMax — justified duplication, keep.
Bind is BindMax with the safe constant baked in. Keeping the default at the shorter name is the whole point.
Disposition: keep. Cost: zero.
6. isConnRefused implemented twice.
packages/borgo/src/api.ts defines a private copy; packages/borgo/src/util.ts exports another (isConnRefused in both). Same predicate, two chances to drift.
Disposition taken in 1.0: one copy, in api.ts, which util.ts hands on. The other direction, as first recommended, would have pulled a server-only module into the browser bundle now that api() ships there.
Migration cost: zero (no public surface involved).
7. filePathToPattern, matchRoute, resolveHead are public on two paths. — landed in 0.21
Re-exported from the root entry and reachable via borgo-framework/router. No application imports them from either.
Disposition taken: dropped from the root entry, and still exported from /router, where the generated routes file already reaches them. No deprecation note: the symbols were undocumented and no known caller existed.
8. SSEHub.Publish, Push, and Channel.publish — three names for "send an event".
Not redundant (SSE hub, Go→front WebSocket relay, browser→relay respectively) but confusing enough that users conflate them.
Disposition: keep the names; fix the docs. realtime should open with a three-line table saying which is which. Cost: documentation.
Exports nobody outside the framework needs#
The Go surface is clean: every exported Go symbol has an application-facing reason to exist. The TypeScript surface is not.
| Export | Entry point | Why it is exported | Disposition | Migration cost |
|---|---|---|---|---|
cookieValue |
root | Nothing. Dead. | removed in 0.21 | zero — unused, undocumented |
registerCsrf |
root | The generated client entry emitted import { registerCsrf, registerIslands } from "borgo-framework" |
moved to borgo-framework/internal in 0.21 |
low — the generated string in build.ts changed; .borgo/ is regenerated on every build |
registerIslands |
root | Same | moved in 0.21 | same |
withCsrf |
root | Used by runtime.ts and util.ts across module boundaries |
moved in 0.21 | zero — cross-module only |
CSRF_COOKIE |
root | Internal constant | moved to borgo-framework/internal in 1.0 |
low — an app that imported it reads the token with csrfCookieValue instead |
browserEnv |
root | The generated client shim of env.ts imports it |
moved to borgo-framework/internal in 1.0 |
zero — the shim is regenerated on every build |
CSRF_FIELD |
root | Internal constant, but arguably useful to an app building a form by hand | kept, stable in 1.0 | zero |
CSRF_HEADER |
root | Same, for an app rolling its own /api fetch instead of using apiFetch |
kept, stable in 1.0 | zero |
filePathToPattern, matchRoute, resolveHead |
root + /router |
Shared between build, server and runtime | dropped from root in 0.21 | low |
safeDecode |
/router |
Shared between router and server | leave; mark the subpath internal | zero |
mount, mountIslands, redirectUrl, asProps |
/runtime |
Generated entries and unit tests | leave; mark the subpath internal | zero |
ApiRouteKey, TopicEvents, TopicEventName, PublishArgs |
root | Inference machinery for api() and subscribe() |
leave; mark internal in docs | zero — removing them would break the public types that reference them |
Route |
root + /router |
Manifest shape | mark internal | zero |
serve |
/server |
Nothing imported the subpath | subpath dropped in 0.21 | it was a breaking change to exports, taken before 1.0 rather than never |
default |
/refresh-runtime |
Generated dev entry | leave; mark internal | zero |
The pattern is clear enough to state as a rule: the root entry point should contain only what an application writes by hand. Everything the generated code needs belongs on a subpath whose name says "not for you".
Naming inconsistencies#
1. The typed-variant convention contradicted itself. — half landed in 0.21
On the response side the plain name is the typed one (JSON[T]) and the untyped one is prefixed (WriteJSON). On the push side it used to be the reverse: PushT was the typed one and plain Push the untyped one, so a user who learned one learned the wrong lesson about the other.
Rule chosen: the plain name is the typed one. The push half landed with finding 2 — Push is now the generic one and there is no second name. The response half is finding 1 and still open.
Cost: the remaining half is finding 1's cost.
2. Push (Go, WebSocket) vs Publish (Go, SSE hub) vs publish (TS, channel).
Three verbs, and the two Go ones differ by transport rather than by intent.
Disposition: keep. Renaming SSEHub.Publish to Push would collide conceptually with borgo.Push, which is worse. Document instead.
Cost: documentation.
3. Only one of the two cookies borgo owns has an exported name.
borgo_csrf is CSRF_COOKIE in TypeScript; borgo_session is the unexported sessionCookie in Go and a string literal in util.ts. Two halves of one convention, exported asymmetrically.
Disposition taken in 1.0: neither. CSRF_COOKIE left the root entry (see above); both cookie names are a documented wire contract rather than an importable symbol.
Cost: zero.
4. Environment variable prefixes are inconsistent.
Most variables are BORGO_*; the exceptions are PORT, API_PORT, API_URL, SESSION_SECRET, SESSION_SECURE and NO_COLOR, plus bun's own BUN_CONFIG_MAX_HTTP_REQUESTS. Those are defensible — PORT and NO_COLOR are ecosystem conventions, SESSION_* is self-describing, and the bun one is not borgo's to rename. The two that were not defensible, METRICS and DEV, were prefixed in 0.21.
Disposition taken: METRICS → BORGO_METRICS and DEV → BORGO_DEV, both in 0.21, neither with an alias. An alias for METRICS was considered and rejected: honouring the old name would preserve the exact collision the prefix exists to end, and an app that wants metrics on an upgrade sets one variable. BORGO_DEV needed no alias either way — it is set only by borgo's own dev loop, so nothing outside the framework was reading it.
5. "Route" means three different things.
TypeScript Route is a page; Go's internal route and ApiRouteKey are api endpoints; filePathToPattern produces a page pattern while Handle takes an api pattern. The docs use "route" for both and rely on context.
Disposition taken in 1.0: Route stays exported and is marked internal, as the table above marks it; no rename. A new name for a type no application writes would be churn in every generated file.
Cost: zero if the type goes internal.
6. Six casings of the brand token, all load-bearing.
//borgo:route, data-borgo-island, __borgo=props, X-Borgo-Action, borgo_session, BORGO_TAILWIND. Each is idiomatic for its medium — Go directives, HTML attributes, query params, HTTP headers, cookies, env — so the inconsistency is real but correct.
Disposition: freeze as-is at 1.0 and document the set. These are wire contracts; renaming any of them breaks stored cookies, running proxies and existing HTML.
Cost: documentation only. Doing it later costs a major version.
Gaps the audit found — all four landed in 0.21#
Not duplication or naming, but things a 1.0 API should have and did not. Every one of them was additive, so all four shipped in 0.21 and are marked stable in the tables above:
- No way to read borgo's version from Go. →
borgo.Version, kept honest by a test that reads.release-please-manifest.json. SSEHubhad no subscriber count and noClose. →(*SSEHub).Subscribers() intand(*SSEHub).Close(), the latter idempotent.- The hash-slot semaphore was not configurable. →
BORGO_HASH_SLOTS, read once at package init; a value that is not a positive integer is logged there and refused byCheckEnv, rather than silently reinstating the default. Serve()could not be composed or tested. →ServeContext(ctx) errorbeside it, rather than changingServe's shape.
No gap of this kind is currently open, and finding 1 was closed in 1.0. What 1.0 leaves open is what is marked provisional above: the additions of 1.0 itself, which have not yet been used outside the framework's own tests and example — the layout loader and the typed auth routes among them. The additions of 1.1 are marked the same way, for the same reason.
What this page is not#
It is not permission to depend on everything listed. Anything marked internal will move without a deprecation cycle. If you find yourself needing an internal export to do something ordinary, that is a bug worth reporting — the fix is usually a new stable API, not a promise about the old one.