TypeScript ยท Fastify reference application

Event Console

A focused operational stream that records structured events and turns validated level and source selections into bounded Trestle queries.

Event Console showing a filtered stream of operational events

What it proves

TypeScript

Strict domain shapes

Event inputs have explicit types, normalized defaults and bounded source and message fields before persistence.

Query safety

Filters are constructed server-side

Fastify accepts only known levels and a constrained source value before composing Trestle's filter expression.

Operational data

Structured context

Each event carries a level, source, message, JSON context and server-generated occurrence timestamp.

Run the example

git clone https://github.com/trestle-cv/dogfood-event-console
cd dogfood-event-console
npm install

export TRESTLE_URL=http://127.0.0.1:7333
export TRESTLE_ADMIN_EMAIL=admin@example.test
export TRESTLE_ADMIN_PASSWORD='choose-a-real-password'

npm run bootstrap
nift build
npm run dev

Start Trestle first and open http://127.0.0.1:4183. Bootstrap creates ec_events, installs service-only record rules and stores a copy-once service credential in ignored owner-only configuration.

Event and query contract

The server accepts debug, info, warn, error and critical levels. It defaults an omitted level to info, rejects blank or oversized source and message values, normalizes non-object context to an empty object and generates occurred_at itself. The list endpoint requests at most 100 records and permits only validated level and source filters.

GET  /api/events?level=error&source=release-worker
POST /api/events

Architecture and authority

browser -> Fastify typed domain API -> Trestle HTTP API -> configured Trestle store

Fastify caps request bodies at 32 KiB and constructs the only allowed collection path. The browser never sees the credential or gains a general-purpose proxy. Trestle owns the durable record and access-control boundary.

Useful checks

npm run check
npm run build:server
npm start