Relocate the ~6k-file docs tree from the repo root into plugins/document-navigator/docs/ so the plugin is self-contained and portable. docs/superpowers/ (specs and plans) stays at the repo root. Moved via cp+rm rather than git mv because directory rename() fails with EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the identical-content files at commit time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5.1 KiB
5.1 KiB
@suaveplan/api-router-in-memory — in-memory router adapter for the @suaveplan/api plugin system. Implements both the abstract Router contract from @suaveplan/api-router AND the PipelineRouter contract from @suaveplan/api-router on a single InMemoryRouter class. Production-grade in-memory adapter — keeps state in process, dispatches without binding a socket. Passes runRouterConformance + runPipelineRouterConformance.
Stage-5 in-memory router adapter for @suaveplan/api. Implements both the abstract Router contract from @suaveplan/api-router AND the PipelineRouter contract from @suaveplan/api-router on a single InMemoryRouter class. Production-grade in-memory adapter — not a test double.
Documentation tree
- adapter —
InMemoryRouteris the Stage-5 in-memory router adapter for@suaveplan/api. It implements both…- adapter —
InMemoryRouteris the Stage-5 in-memory router adapter for@suaveplan/api. It implements both…
- adapter —
- blue-green-slot —
InMemoryBlueGreenSlotis theBlueGreenSlotimplementation paired withInMemoryRouter. It is a thin extension of `…- blue-green-slot —
InMemoryBlueGreenSlotis theBlueGreenSlotimplementation paired withInMemoryRouter. It is a thin extension of `…
- blue-green-slot —
- error-codes — Defines the stable
ROUTER_IN_MEMORY.*error-code namespace used by every production path in `@suaveplan/api-router-in…- error-codes — Defines the stable
ROUTER_IN_MEMORY.*error-code namespace used by every production path in `@suaveplan/api-router-in…
- error-codes — Defines the stable
- pipeline —
PipelineRouteTableis the in-memory metadata store that backsInMemoryRouter's pipeline facet. It stores per-route…- pipeline —
PipelineRouteTableis the in-memory metadata store that backsInMemoryRouter's pipeline facet. It stores per-route…
- pipeline —
- testing —
createInMemoryRouterHarness()is the canonical "spin up an in-memory router for a test" entry point. It bundles a fre…- testing —
createInMemoryRouterHarness()is the canonical "spin up an in-memory router for a test" entry point. It bundles a fre…
- testing —
What it ships
InMemoryRouter/createInMemoryRouter()— concreteRouteradapter that subclasses the abstract base AND exposes the pipeline facet (registerPipelineRoute,matchPipeline,listPipelineRoutes,unregisterPipelineRoute,unregisterPipelinePlugin).InMemoryBlueGreenSlot/createInMemoryBlueGreenSlot— hot-reload primitive paired with the router. Thin extension of@suaveplan/api-router's referenceInMemoryBlueGreenSlot.PipelineRouteTable— the in-memory metadata store backing the pipeline facet, exported for advanced use cases that need to share a table across routers.createInMemoryRouterHarness()— downstream test helper that bundles a router + slot factory pair, replacing the hand-rolled router shims that have grown across the foundation + plugin tests.ROUTER_IN_MEMORY_CODES/RouterInMemoryError— stable error-code registry (ROUTER_IN_MEMORY.ROUTE_COLLISION,ROUTER_IN_MEMORY.INVALID_PREFIX).
Conformance
The package passes BOTH foundation conformance suites:
runRouterConformancefrom@suaveplan/api-router/testing— seetests/conformance/api-router.test.ts.runPipelineRouterConformancefrom@suaveplan/api-router/testing/pipeline-router-conformance— seetests/conformance/pipeline-router.test.ts.
Adding new behaviours requires re-running both harnesses.
Modules
src/adapter/adapter.md—InMemoryRouter+ factory.src/blue-green-slot/blue-green-slot.md— hot-reload primitive.src/pipeline/pipeline.md—PipelineRouteTable+ types.src/testing/testing.md—createInMemoryRouterHarnessfor downstream tests.src/error-codes/error-codes.md—ROUTER_IN_MEMORY.*registry.
Usage
import {
createInMemoryRouter,
InMemoryBlueGreenSlot,
} from "@suaveplan/api-router-in-memory";
const router = createInMemoryRouter({ plugin: "billing" });
router.get("/invoices/:id", () => null);
router.registerPipelineRoute({
plugin: "billing",
method: "POST",
path: "/invoices",
handler: async () => ({ ok: true }),
});
const slot = new InMemoryBlueGreenSlot("billing", () => "v1");
slot.setShadow(() => "v2");
const draining = slot.flip();
await slot.dispose(draining.slotId, { timeoutMs: 100 });
When to use
- Foundation tests that need a real
Router/PipelineRouterwithout a Hono peer. - Plugin tests that previously hand-rolled their own router shim (
api-router-honocarries the Hono peer-dep cost). - The default
router: "in-memory"slot in the Stage-5@suaveplan/api-host/testingadapter table.