Skip to content

Commit

Permalink
fix(output-validation): 🐛 return zod transformed object rather than p…
Browse files Browse the repository at this point in the history
…re-validation object
  • Loading branch information
evertdespiegeleer committed Oct 11, 2024
1 parent 6da1570 commit 1a75c60
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/core/src/util/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ export const endpointToExpressHandler = (endpoint: AnyEndpoint) => {
.getHandler()?.(inputParams, req, res)
.then((responseObj) => {
// Output validation
let postOutputValidationResponseObj: z.output<ReturnType<typeof endpoint.getResponseValidationSchema>> | undefined
try {
endpoint.getResponseValidationSchema()?.parse(responseObj)
postOutputValidationResponseObj = endpoint.getResponseValidationSchema()?.parse(responseObj)
} catch (error) {
const e = error as z.ZodError
loggerInstance.logger('endpointOutputValidation').error(e)
Expand All @@ -289,7 +290,7 @@ export const endpointToExpressHandler = (endpoint: AnyEndpoint) => {
}

res.header('content-type', endpoint.getResponseContentType())
res.send(responseObj)
res.send(postOutputValidationResponseObj)
})
.catch((e) => {
next(e)
Expand Down

0 comments on commit 1a75c60

Please sign in to comment.