apistockdocs
v0.4 GitHub apistock.dev
Technical

Package reference

Every public package of the apistock library, generated from its Go doc comments on each build, so it always matches the code. Each page shows the package's constants, variables, functions and types with their documentation. Generated apps import these packages; test helpers are for your tests.

Core packages#

PackageWhat it does
actorPackage actor records who is performing an operation, in a context.Context.
appPackage app runs an application's long-running work and shuts it down in a defined order.
auditPackage audit defines audit events and the Recorder contract that any module uses to record who did what to which resource, and whether it worked.
buildinfoPackage buildinfo reports the version, commit and build time of the running binary, from Go build information or a version set at link time.
configPackage config provides configuration helpers for the composition root of an apistock app: a Secret type that never leaks into logs or output, and environment lookup with *_FILE support for mounted secrets.
healthPackage health serves liveness and readiness endpoints.
httpxPackage httpx provides the HTTP foundation of an apistock app: a server that runs under app.Run with safe timeouts, security middleware, and the RFC 9457 problem+json error contract with an application-owned error mapping (ADR-0018).
mailPackage mail defines email messages and the Sender contract implemented by provider modules such as mail/resend and mail/smtp (ADR-0025).
pagePackage page provides cursor pagination and sorting for list endpoints: bounded limits, opaque cursors and allowlisted sort fields.
ratelimitPackage ratelimit provides in-memory token-bucket rate limiting keyed by a string (an IP address, account or API key) and HTTP middleware.
requestidPackage requestid generates, validates and carries request IDs in a context.Context, so HTTP middleware, logging, audit and jobs share one correlation value (ADR-0030).

Module packages#

PackageWhat it does
modules/auditpgPackage auditpg stores audit events in PostgreSQL and queries them for operator APIs (ADR-0036).
modules/authPackage auth provides the building blocks of email and password authentication: argon2id password hashing, session tokens and one-time codes stored only as hashes, email normalisation, session cookies, the request middleware, a permission catalog and plain authentication emails (ADR-0024, ADR-0038).
modules/auth/passkeyPackage passkey provides passkeys (WebAuthn) for apps: registration and sign-in ceremonies checked against the relying party's ID and allowed origins, credential records to store, and the association files native apps need (ADR-0044).
modules/auth/socialPackage social signs people in with Google and Apple (ADR-0046): the web authorization code flow with state, nonce and PKCE, ID tokens from native apps checked against the app's client IDs, and Apple's client secret, token revocation and server-to-server notifications.
modules/jobsPackage jobs runs background jobs on PostgreSQL with River (ADR-0033).
modules/mail/resendPackage resend sends email with Resend (https://resend.com) through its HTTP API (ADR-0025, ADR-0037).
modules/mail/smtpPackage smtp sends email through any SMTP server: Amazon SES, Postmark, Mailgun, Google Workspace, your own server, or Mailpit in development (ADR-0025, ADR-0037).
modules/openapiPackage openapi integrates Huma with apistock (ADR-0027): an API on the standard http.ServeMux, problem+json errors produced by the application's error mapper, an API reference at /docs in the apistock design (ADR-0049, rendered by package reference), and OpenAPI export.
modules/openapi/referencePackage reference renders an OpenAPI 3.1 document as an API reference in the apistock design (ADR-0049): an overview, and a page per operation with its parameters, responses, request examples in curl, Go and TypeScript, response examples and "Try it".
modules/orgsPackage orgs holds the building blocks for organisations in multi-tenant apps (ADR-0023, ADR-0048): organisation IDs, the membership check every organisation operation starts with, and invitation emails.
modules/postgresPackage postgres connects apistock apps to PostgreSQL: a pgx connection pool with OpenTelemetry tracing, transactions, error classification for repositories, a readiness check and goose migrations (ADR-0005, ADR-0032).
modules/releasesPackage releases records which build every instance of an app runs and answers which releases are running (ADR-0040).
modules/settingsPackage settings provides runtime settings: non-secret tunables declared in Go with a default and bounds, stored in PostgreSQL only when changed, and applied on every instance without a restart (ADR-0031).
modules/telemetryPackage telemetry sets up OpenTelemetry tracing and metrics and structured logs correlated with requests and traces (ADR-0007).

Test helpers#

PackageWhat it does
modules/auth/passkey/passkeytestPackage passkeytest is a software passkey authenticator for tests.
modules/auth/social/socialtestPackage socialtest runs an in-process OpenID Connect provider standing in for Google or Apple in tests: it serves signing keys, a token endpoint and a revocation endpoint, and issues signed ID tokens, authorization codes and Apple notifications.
modules/postgres/pgtestPackage pgtest gives each test its own PostgreSQL database on the Docker PostgreSQL server started with `docker compose up -d --wait` (ADR-0028).
v0.4
esc
↑↓ move↵ openesc close