API Reference

ActionRouter

Instance member (public)PurposeConcept reference
useRegisters a middleware functionRead more
branchCreates a branch diversionRead more
inputRegisters a zod schemaRead more
runRegisters a action handler functionRead more

ActionHandler params

ActionRequest object

PropTypePurposeInitial Value
contextInitially, { inputs: void }, for rest of the middlewares and action handlers it depends upon chaining flowContains context information for each request like inputs and can be extended to inject dependencies like database instance, helper methods, etc{ inputs: null }
cookiesReadonlyRequestCookiesProvides request cookiesheaders()
headersReadonlyHeadersProvides request headerscookies()

ActionResponse object

PropTypePurpose
dataFunction, (data: any) => ({ success: true, data })Takes any data and returns a data response object
errorFunction, (code: string, message?: string) => ({ success: false, error: { code, message } })Takes error code which is pre-defined in router config and a optional message override to the default message of the error code and returns an error response object.
createErrorFunctionWorks just like error function but useful when you need to create an inferrable error code just in time
notFoundFunctionThrows notFound error
redirectFunctionThrows redirect error