@noego/dinner
v2.3.0
Published
Portable v1 backend executor
Readme
@noego/dinner
Portable backend executor for noego projects. @noego/app compiles an
OpenAPI document (paths, x-controller / x-action, x-middleware,
schemas) into an executable binding; dinner turns that binding into a
(request: Request, context) => Promise<Response> application that runs
unchanged on Node and Cloudflare Workers.
import { createBackendApplication } from '@noego/dinner';
const application = createBackendApplication(binding, {
contextBuilder, // per-request scoped IoC container
controllerBuilder, // DI-instantiate the controller class
});Controllers are classes; an action receives an Express-ish compat pair:
import type { CompatRequest, CompatResponse } from '@noego/dinner';
export default class TodosController {
async getTodos({ req, res }: { req: CompatRequest; res: CompatResponse }) {
return res.json({ items: [] });
}
}Request validation uses Ajv against the operation schemas; builds may
supply precompiled standalone validators (route.validators) for runtimes
that forbid code generation (Workers).
Portable middleware uses this contract:
type PortableMiddleware = (
context: BackendRequestContext,
next: () => Promise<Response | void>,
) => Response | void | Promise<Response | void>;Middleware may return a Response, await and return next(), or return
nothing when the surrounding pipeline is responsible for the final response.
Exports: createBackendApplication, computeOperationSchemas,
VALIDATION_AJV_OPTIONS, createCompatPair, matchRoute,
allowedMethods, and the binding/route types.
