Start an ephemeral in-memory KV host:
pnpm --filter triplex-http-api-example startOr persist through SQLite:
pnpm --filter triplex-http-api-example start --sqlite ./triplex.sqliteThe host uses Effect CLI for argument validation and help:
pnpm example:http-api --help
pnpm example:http-api --sqlite ./triplex.sqlite --host 127.0.0.1 --port 3001The defaults are in-memory storage, host 127.0.0.1, and port 3000. Use --port 0
to allocate an available port. The example logs documentation URLs with the bound
address after configuration deployment and server startup succeed. Database and
HTTP resources share the Effect layer lifecycle and are closed on shutdown.
The example persists two configuration deployments and keeps both documentation versions mounted:
http://127.0.0.1:3000/api/rest/v1/docs—Employeewith only:employee/namehttp://127.0.0.1:3000/api/rest/v2/docs— adds optional:employee/emailhttp://127.0.0.1:3000/api/rest/latest/docs— the v2 contract at the writableliveref
The immutable v1 and v2 aliases are read-only, so their OpenAPI documents show reads only.
latest demonstrates the same v2 schema with write operations enabled.
Create and read employees through the current deployment:
curl -i -X POST http://127.0.0.1:3000/api/rest/latest/employees \
-H 'content-type: application/json' \
--data '{"attributes":{":employee/name":"Ada",":employee/email":"ada@example.com"}}'
curl http://127.0.0.1:3000/api/rest/latest/employees
curl http://127.0.0.1:3000/api/rest/latest/openapi.jsonTo compare the raw contracts instead of the interactive UI:
curl http://127.0.0.1:3000/api/rest/v1/openapi.json
curl http://127.0.0.1:3000/api/rest/v2/openapi.jsonThe generated contracts are checked in as readable JSON:
Tests request each OpenAPI endpoint through the same configuration deployment and
routes used by the server, with a fresh in-memory database and no listening socket.
They preserve the actual deterministic configuration IDs and use the repository's
JSON formatting. Missing or changed snapshots fail pnpm check without rewriting files.
After an intentional schema or generator change, regenerate and inspect the diff:
pnpm --filter triplex-http-api-example snapshots:update
git diff -- examples/http-api/test/openapiCommit the updated JSON alongside the change. Git keeps the running history of each contract; inspect it with:
git log -p -- examples/http-api/test/openapi/latest.jsonTo check just the example snapshots, run pnpm --filter triplex-http-api-example test.
This example deliberately installs the explicit allow-all authorization layer. Real hosts should
provide an application policy through HttpAuthorization.