Fastify plugin for ObjectStack — registers the auto-generated REST API and dispatcher as a Fastify plugin.
Exposes ObjectStack as a standard Fastify plugin. Auth, storage, GraphQL, and discovery routes are handled explicitly; everything else is served by a catch-all delegating to HttpDispatcher, so protocol evolution does not require adapter changes.
pnpm add @objectstack/fastify fastifyimport Fastify from 'fastify';
import { objectStackPlugin } from '@objectstack/fastify';
import { kernel } from './my-kernel';
const app = Fastify({ logger: true });
await app.register(objectStackPlugin, { kernel, prefix: '/api' });
await app.listen({ port: 3000 });import { objectStackDecorator } from '@objectstack/fastify';
app.decorate('objectstack', objectStackDecorator(kernel));| Export | Kind | Description |
|---|---|---|
objectStackPlugin |
fastify plugin | Registers all dispatcher routes under prefix. |
objectStackDecorator(kernel) |
function | Returns a decorator that exposes the dispatcher on the Fastify instance. |
FastifyAdapterOptions |
interface | { kernel, prefix? }. |
| Option | Type | Default |
|---|---|---|
kernel |
ObjectKernel |
— |
prefix |
string |
'/api' |
Register the ObjectStack plugin after body parsing, CORS, and authentication preprocessors. Do not enable Fastify's automatic schema validation on ObjectStack routes — the protocol does its own Zod validation.
- ✅ Fastify applications needing high-throughput APIs.
- ✅ Teams already invested in Fastify's plugin ecosystem.
- ❌ Edge / serverless Workers — use
@objectstack/hono.
- 📖 Docs: https://objectstack.ai/docs
- 📚 API Reference: https://objectstack.ai/docs/references
Apache-2.0 © ObjectStack