RouteIO acts as a mapper, tasked with converting data from the request into input for the controller, and the controller's result into the response. Each route, if it provides or returns data, is automatically assigned a RouteIO where this data parsing should be performed. RouteIO contains two optional methods (toResponse, fromRequest), depending on whether the route expects or/and returns data.
exportclassGetCustomerDetailsRouteIOimplemetsRouteIO {publictoResponse(output:Result<Customer>):Response {if (result.isFailure) {// decide on the status type and contentreturnresponse.status(500).send(result.failure.error.message); }const { ... } =result.content;// map result content to output if neededreturnresponse.status(200).send({...}); }publicfromRequest(request:Request):string {returnrequest.params.id; }}