Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@objectstack/fastify

Fastify plugin for ObjectStack — registers the auto-generated REST API and dispatcher as a Fastify plugin.

npm License: Apache-2.0

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 fastify

Quick 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

Related Packages

Links

License

Apache-2.0 © ObjectStack