Upgrade Guide
Upgrading to v1.10
Lifecycle hooks, build targets, CLI, and config changes
Upgrading to v1.10
Lifecycle Hooks
The builder methods have been renamed for clarity:
| Before | After |
|---|---|
onReady(fn) | onStart(fn) |
onClose(fn) | onStop(fn) |
.build() | .buildApi() |
TelaioApp | TelaioApi |
onStart callbacks now run inside start() instead of Fastify's onReady hook.
onStop callbacks now run inside stop() instead of Fastify's onClose hook.
Build Targets
The builder now has two build methods:
buildApi()-- creates a full Fastify server (replacesbuild())buildConsumer()-- creates a lightweight queue worker (replacesstartConsumer())
Before
import { createApp } from 'telaio';
import { startConsumer } from 'telaio/queue';
// API
const app = await createApp({ config }).withDatabase().build();
await app.start();
// Consumer (separate file)
await startConsumer(registry, { connection: config });After
import { createApp } from 'telaio';
// app.ts -- shared builder
export function getBuilder() {
return createApp({ config }).withDatabase().withQueues(registry);
}
// server.ts
const server = await getBuilder().buildApi();
await server.start();
// consumer.ts
const consumer = await getBuilder().buildConsumer();
await consumer.start();CLI Changes
| Removed | Replacement |
|---|---|
telaio dev | run-p with tsx watch (or similar) |
telaio consumer | buildConsumer() in a plain TypeScript entry point |
New flags:
telaio gen-client --watch-- watchsrc/and regenerate on changestelaio db-types --watch-- watch migration files and regenerate
Config Changes
The consumer and dev keys in defineConfig() and package.json are no longer used and can be removed.