Sub-issue of #488. webjs has root + per-segment middleware.js but no composable PER-ACTION middleware that accumulates typed context (auth, logging, rate-limit, db transaction declared on the action). TanStack Start models this well with createMiddleware (request + function middleware types, typed context accumulation through the chain, per-middleware validators).
Design / approach
A composable per-action middleware primitive that runs around an action's execution (RPC path and route.ts boundary), accumulating typed context the handler receives. It must compose with the #488 config-export model (a sibling export const middleware = [...] on the action file) and with validate. Decide: a createMiddleware-style builder vs a plain array of (ctx, next) => ... functions (webjs's existing middleware shape). Typed context accumulation is the hard, high-value part for DX. Server-only.
Acceptance criteria
Sub-issue of #488. webjs has root + per-segment
middleware.jsbut no composable PER-ACTION middleware that accumulates typed context (auth, logging, rate-limit, db transaction declared on the action). TanStack Start models this well withcreateMiddleware(request+functionmiddleware types, typed context accumulation through the chain, per-middleware validators).Design / approach
A composable per-action middleware primitive that runs around an action's execution (RPC path and route.ts boundary), accumulating typed context the handler receives. It must compose with the #488 config-export model (a sibling
export const middleware = [...]on the action file) and withvalidate. Decide: acreateMiddleware-style builder vs a plain array of(ctx, next) => ...functions (webjs's existing middleware shape). Typed context accumulation is the hard, high-value part for DX. Server-only.Acceptance criteria
validateand the verb/cache config.