@objectstack/fastify
v7.0.0
Published
Fastify adapter for ObjectStack — mounts the generated REST API onto a Fastify app.
Maintainers
Readme
@objectstack/fastify
Fastify plugin for ObjectStack — registers the auto-generated REST API and dispatcher as a Fastify plugin.
Overview
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.
Installation
pnpm add @objectstack/fastify fastifyQuick Start
import 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 });Decorator mode
import { objectStackDecorator } from '@objectstack/fastify';
app.decorate('objectstack', objectStackDecorator(kernel));Key Exports
| 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? }. |
Configuration
| Option | Type | Default |
|:---|:---|:---|
| kernel | ObjectKernel | — |
| prefix | string | '/api' |
Middleware order
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.
When to use
- ✅ Fastify applications needing high-throughput APIs.
- ✅ Teams already invested in Fastify's plugin ecosystem.
When not to use
- ❌ Edge / serverless Workers — use
@objectstack/hono.
Related Packages
Links
- 📖 Docs: https://objectstack.ai/docs
- 📚 API Reference: https://objectstack.ai/docs/references
License
Apache-2.0 © ObjectStack
