Repository navigation
v0.2.0
kzig 0.2.0 adds scheduled jobs, file storage and a database layer, and moves the docs to
https://forinda.github.io/kzig/, with a tutorial from
kzig new to a Docker image. Requires Zig 0.17.0. Pre-alpha: APIs will change.
Highlights
Database (kzig.db)
kick/db's code-first layer, in Zig.
-
Postgres without libpq. A pure-Zig client with SCRAM-SHA-256, a pool and transactions, and rows decoded into structs by column name.
- TLS follows libpq's
sslmode, withsslrootcertor the system's CAs, andsslnegotiation=direct(Postgres 17). - Channel binding (SCRAM-SHA-256-PLUS).
- Client certificates on TLS 1.3 and 1.2: EC, RSA and Ed25519 keys, encrypted keys with
sslpassword. - Revocation lists (
sslcrl).
- TLS follows libpq's
-
Schema and queries. Tables are Zig struct literals. The query builder covers select, insert, update, delete, joins,
upsert,findOrCreateandinsertMany, and a wrong column or value type is a compile error. -
Relations.
one,manyandthroughare resolved with kick/db's rules.client.query(.t).findMany(.{ .with = … })reads nested rows in one statement. -
Migrations.
kzig db generatewrites kick/db's migration folders from your schema, with renames by prompt or flag;kzig db checkis for CI.kzig db migrate,rollbackandstatus, orkzig.db.migrate.onBoot, apply them, so a kick/db app and a kzig app can share a folder. -
SQLite, Turso and Cloudflare D1. The same schema, builder, relations and migrations, in three forms:
sqlite:pathfor local files. Needs-Dsqlite, which builds SQLite's C library; the default build stays C-free.libsql://for Turso, over HTTP.d1://for D1, over its REST API.
On SQLite, Turso and D1, parameters bind by their Zig type.
Also new
- Scheduled jobs.
pub const crons = .{ … }on any service: 5- or 6-field expressions checked at compile time, timezones from zoneinfo, overlap control, manual runs. - Storage.
kzig.storageover memory, a disk folder, or S3 (AWS, R2, MinIO, SeaweedFS), with SigV4 signing (no SDK), presigned links and listing. - Routing. Routes now match through a segment tree built at compile time.
Docs
- The guides moved from the README to a site built with MkDocs (Material).
- The API reference is built from the source by Zig's autodoc, at /api/.
- The tutorial builds a bookmarks API: SQLite with migrations, validation, an API key, Swagger UI, tests, production settings and a 25 MB Docker image.
Changes to note when upgrading
Pool.queryParams/execParams(and theTxversions) take[]const kzig.db.Param; wrap raw text withkzig.db.Param.texts(arena, values).kzig db generateandkzig db checkneed--db <name>when the app has more than one database adapter with a schema.
Install
zig fetch --save git+https://github.com/forinda/kzig#v0.2.0Prebuilt kzig CLIs for Linux (x86_64, aarch64) and macOS (x86_64, arm64) are attached below, with SHA256SUMS.