Skip to content

Lifecycle

Master the oRPC lifecycle to confidently implement and customize your procedures.

Overview

oRPC Lifecycle
NameDescriptionCustomizable
HandlerProcedures defined with .handler.
MiddlewaresProcedures added via .use.
Input ValidationValidates input data against the schema specified in .input.🟡
Output ValidationEnsures output data conforms to the schema defined in .output.🟡
Client InterceptorsInterceptors executed before Error Validation.
Error ValidationFlags errors as defined and validate error data if they match the schema in .errors.🟡
RoutingDetermines which procedure to execute based on the incoming request.
InterceptorsInterceptors executed before the Error Handler.
Error HandlerCatches errors and converts them into a response.🟡
Root InterceptorsModify the request or response as needed.

Note: The components Routing, Interceptors, Error Handler, and Root Interceptors are not available when using the server-side client.

Middlewares Order

To ensure that all middlewares run after input validation and before output validation apply the following configuration:

ts
const base = os.$config({
  initialInputValidationIndex: Number.NEGATIVE_INFINITY,
  initialOutputValidationIndex: Number.NEGATIVE_INFINITY,
})

INFO

By default, oRPC executes middlewares based on their registration order relative to validation steps. Middlewares registered before .input run before input validation, and those registered after .output run before output validation.

Released under the MIT License.