Skip to content

Commit 2ae2e03

Browse files
committed
refactor: remove 'ok' property from ApiResponse. output should not be undefined
1 parent 433ee66 commit 2ae2e03

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

packages/api/src/api.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export class BaseApi<Req extends ApiRequest, Ctx extends ApiContext> {
3939
const ctx = {} as Ctx;
4040
const res: ApiResponse = {
4141
output: undefined,
42-
ok: false,
4342
};
4443
const execute = () =>
4544
opts.action({
@@ -69,12 +68,11 @@ export class BaseApi<Req extends ApiRequest, Ctx extends ApiContext> {
6968
} as any,
7069
async (opts) => {
7170
res.output = await execute();
72-
res.ok = true;
7371
return opts.next();
7472
},
7573
);
7674

77-
if (!res.ok) {
75+
if (res.output === undefined) {
7876
throw new ApiError({
7977
message:
8078
'The action function or middleware(s) did not set a valid output. Please ensure the output is defined and valid.',
@@ -100,8 +98,7 @@ export class BaseApi<Req extends ApiRequest, Ctx extends ApiContext> {
10098
req,
10199
res,
102100
execute,
103-
} as any);
104-
res.ok = true;
101+
});
105102
} else {
106103
throw error;
107104
}

packages/api/src/client/middleware/refreshToken.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export function refreshToken<R extends AnyAsyncFn>(options: {
4242
.then((value) => options.beforeRetry?.(value, {}))
4343
.then(async () => {
4444
opts.res.output = await opts.execute();
45-
opts.res.ok = true;
4645
})
4746
.finally(() => {
4847
refreshing = null;

0 commit comments

Comments
 (0)