Skip to content

Commit

Permalink
[publish] version 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
leomerida15 committed Oct 18, 2023
1 parent f3ce8d4 commit 85b796d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.7.10",
"version": "0.8.0",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
16 changes: 9 additions & 7 deletions src/resolvers/yup/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const yupRoute = <
const controllerFactory = (
nextRequest: NextRequest,
context: InferType<C>,
): void => {
) => {
try {
const { schemas, Handler } = ((): {
schemas?: IYupRouteParams<B, C, Q, H, R>["schemas"];
Expand All @@ -33,15 +33,17 @@ export const yupRoute = <
};
})();

requestFactory<B, C, Q, H, R>(nextRequest, context, schemas).then(
(req) => {
return requestFactory<B, C, Q, H, R>(nextRequest, context, schemas)
.then((req) => {
const reply = responseFactory(schemas?.response);

Handler(req, reply, context);
},
);
return Handler(req, reply, context);
})
.finally();
} catch (error) {
NextResponse.json((error as any).errors, { status: 400 });
return NextResponse.json((error as any).errors, {
status: 400,
}) as Response;
}
};

Expand Down
19 changes: 9 additions & 10 deletions src/resolvers/zod/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ export const zodRoute = <
>(
P: IZodRouteParams<B, C, Q, H, R> | IZodRouteParams<B, C, Q, H, R>["Handler"],
) => {
const controllerFactory = (
nextRequest: NextRequest,
context: TypeOf<C>,
): void => {
const controllerFactory = (nextRequest: NextRequest, context: TypeOf<C>) => {
try {
const { schemas, Handler } = ((): {
schemas?: IZodRouteParams<B, C, Q, H, R>["schemas"];
Expand All @@ -33,15 +30,17 @@ export const zodRoute = <
};
})();

requestFactory<B, C, Q, H, R>(nextRequest, context, schemas).then(
async (req) => {
return requestFactory<B, C, Q, H, R>(nextRequest, context, schemas)
.then((req) => {
const reply = responseFactory(schemas?.response);

Handler(req, reply, context);
},
);
return Handler(req, reply, context);
})
.finally();
} catch (error) {
NextResponse.json((error as any).errors, { status: 400 });
return NextResponse.json((error as any).errors, {
status: 400,
}) as Response;
}
};

Expand Down

0 comments on commit 85b796d

Please sign in to comment.