Tern

Packages

These are Tern's first-party packages: maintained with the language, but not part of the standard library. Two kinds:

  • roost, auth, openapi, sentry, grpc, queue, pg, migrate and sqlgen live in repositories of their own. tern add roost puts one in your project's tern.mod and fetches it into deps/ (an installed Tern carries a copy of each, so this works offline). The web template (tern new NAME --template web) adds roost, auth and migrate for you, and the tern migrate and tern sqlgen commands run Tern's own copies.
  • sqlite and redis are packages too, but for now they come with Tern, because the runtime works closely with them: a program just imports them.

They're written the way any package is: see Writing and publishing a package to make your own.

PackageWhat it's for
roostA web framework on the http engine: routing, middleware, WebSockets, SSE, static files, uploads, validation, rate limits, metrics
sqliteSQLite databases with bound parameters and typed row reading
pgA PostgreSQL client with a connection pool shared by tasks
redisA Redis client with automatic pipelining
migrateSchema migrations for PostgreSQL and SQLite from numbered .sql files: up, down, status, locking
sqlgenTyped Tern functions generated from SQL queries, checked against PostgreSQL or SQLite (like sqlc)
authJSON Web Tokens and signed-cookie sessions
openapiOpenAPI 3.1 documents, Swagger UI and a typed TypeScript client from roost routes described with Tern types
sentryError reporting to Sentry: runtime errors with stack traces, request data, breadcrumbs

Two more have no page yet; their API is the comment at the top of their source, in deps/grpc/grpc.tn and deps/queue/queue.tn once added: grpc (gRPC over HTTP/2) and queue (a client for the ternq broker). tern guide NAME prints any package's API.