Express adapter for ObjectStack — mounts the auto-generated REST API and route dispatcher onto an Express app.
Wraps HttpDispatcher from @objectstack/runtime as an Express Router (or request middleware). All ObjectStack routes — CRUD, batch, metadata, discovery, auth, storage, GraphQL — are handled by a catch-all that delegates to the dispatcher, so new protocol routes work automatically without adapter updates.
pnpm add @objectstack/express expressimport express from 'express';
import { createExpressRouter } from '@objectstack/express';
import { kernel } from './my-kernel';
const app = express();
app.use(express.json());
app.use('/api', createExpressRouter({ kernel }));
app.listen(3000);import { objectStackMiddleware } from '@objectstack/express';
app.use(objectStackMiddleware(kernel));| Export | Kind | Description |
|---|---|---|
createExpressRouter(options) |
function | Returns a mounted Router with all ObjectStack dispatchers. |
objectStackMiddleware(kernel) |
function | Per-request middleware (use for custom routing/prefix). |
ExpressAdapterOptions |
interface | { kernel: ObjectKernel, prefix?: string }. |
| Option | Type | Default | Notes |
|---|---|---|---|
kernel |
ObjectKernel |
— | Bootstrapped kernel from @objectstack/core. |
prefix |
string |
'/api' |
Base path for the mounted router. |
express.json() (or an equivalent body parser) MUST be registered before the ObjectStack router. Auth cookies require cookie-parser if you use cookie sessions. The adapter sets response headers directly; do not wrap with compression middleware that rewrites JSON bodies before the router.
- ✅ Adding ObjectStack to an existing Express app.
- ✅ Node.js deployments without edge runtime constraints.
- ❌ Edge / Workers — use
@objectstack/honoinstead. - ❌ Next.js App Router — use
@objectstack/nextjs.
@objectstack/runtime— providesHttpDispatcher.@objectstack/rest— route registration used by the dispatcher.@objectstack/core— kernel.
- 📖 Docs: https://objectstack.ai/docs
- 📚 API Reference: https://objectstack.ai/docs/references
Apache-2.0 © ObjectStack