Integrations
Express
Mount Katman as Express middleware — run RPC and REST routes on the same server.
If you have an existing Express application, Katman can be mounted as middleware alongside your REST routes.
Setup
import from "express"
import { } from "katman/express"
const = ()
.(.()) // Required for POST body parsing
// Existing routes
.("/api/health", (, ) => .({ : "ok" }))
// Katman RPC under /rpc
.("/rpc", (appRouter, {
: () => ({
: getDB(),
: .user,
: .ip,
}),
}))
.(3000)Context from Express
The context function receives the Express request object. Bridge your existing auth middleware, IP detection, and headers:
katmanExpress(appRouter, {
: () => ({
: .user, // from passport or similar
: .ip,
: .headers,
}),
})Route behavior
- Procedures are matched by the path after the mount prefix
POST /rpc/users/list→ callsusers.listwith the JSON body as inputGET /rpc/users/list?data={"limit":10}→ callsusers.listwith parsed query data- Unmatched paths pass through to the next Express middleware (
next())
Make sure express.json() middleware is registered before the Katman middleware — otherwise POST bodies won't be parsed.
What's next?
- Fastify — Fastify plugin adapter
- Server — standalone
serve()as an alternative - Integrations — other available integrations