Skip to content

Commit

Permalink
Make args accessible in fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
renatodellosso committed Feb 18, 2025
1 parent 7a8fb6e commit c7e83c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unified-api",
"version": "1.0.24",
"version": "1.0.25",
"description": "Easily create and call APIs in Typescript",
"author": "Decatur Robotics",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export type Route<
(...args: TArgs): Promise<TReturn>;
beforeCall?: (args: TArgs) => Promise<TArgs>;
afterResponse?: (res: TReturn, ranFallback: boolean) => Promise<void>;
fallback?: (res: TReturn) => Promise<TReturn>;
fallback?: (...args: TArgs) => Promise<TReturn>;

isAuthorized: (
req: TRequest,
Expand Down Expand Up @@ -157,7 +157,7 @@ export class RequestHelper {

if (res?.error) {
if (parsedRoute.fallback) {
return parsedRoute.fallback?.(res).then((res) => {
return parsedRoute.fallback?.(...body).then((res) => {
parsedRoute.afterResponse?.(res, true);
return res;
});
Expand Down

0 comments on commit c7e83c3

Please sign in to comment.