stable

rest

Framework-neutral REST handler — createRestHandler({ store, user }) with /hono, /express, /fastify, /nitro subpath adapters.

@noy-db/in-rest · pnpm add @noy-db/hub @noy-db/in-rest Serve a vault over HTTP — framework-neutral REST API integration for noy-db.

What it does

createRestHandler({ store, user, ttlSeconds?, basePath? }) builds a NoydbRestHandler — a plain handle(req: RestRequest): Promise<RestResponse> function — against a framework-neutral request/response shape. Session state (ttlSeconds, default 900) is tracked internally by a SessionStore. The /hono, /express, /fastify, and /nitro subpath adapters wrap that handler for each server framework, so the routing logic is written once and reused everywhere.

The framework you pick is an optional peer. Since 0.7.0-pre.9 the package declares h3, hono, express and fastify as optional peerDependencies with real version ranges (noy-db#1241). Each adapter subpath statically imports its framework, so previously they were undeclared runtime imports — no version range, and nothing for a resolver to check. Install the one you use; the others stay absent and unresolved.
pnpm add @noy-db/in-rest hono     # or express@^5 / fastify@^5 / h3@^1.13

Usage

import { createRestHandler } from '@noy-db/in-rest'
import { honoAdapter } from '@noy-db/in-rest/hono'

const handler = createRestHandler({ store, user: 'api' })
app.route('/api/noydb', honoAdapter(handler))

See also

  • in-* family
  • ai — another protocol-facing binding, for LLM tool-calling instead of HTTP