createGateway
createGateway<
TBindings>(config):GatewayInstance
Defined in: src/core/gateway.ts:100
Create a gateway instance from a declarative configuration.
Registers all routes on a Hono app, builds per-route policy pipelines
(merging global + route-level policies), and wires up upstream dispatch.
Returns a GatewayInstance whose .app property is the Hono app
ready to be exported as a Cloudflare Worker default export.
Type Parameters
Section titled “Type Parameters”TBindings
Section titled “TBindings”TBindings = Record<string, unknown>
Parameters
Section titled “Parameters”config
Section titled “config”GatewayConfig<TBindings>
Full gateway configuration including routes, policies, and options.
Returns
Section titled “Returns”A GatewayInstance with the configured Hono app.
Throws
Section titled “Throws”If no routes are provided.
Example
Section titled “Example”import { createGateway, jwtAuth, rateLimit } from "@homegrower-club/stoma";
const gateway = createGateway({ name: "my-api", basePath: "/api", routes: [ { path: "/users/*", pipeline: { policies: [jwtAuth({ secret: env.JWT_SECRET }), rateLimit({ max: 100 })], upstream: { type: "url", target: "https://users-service.internal" }, }, }, ],});
export default gateway.app;