chore: hook context returned type should be optional

This commit is contained in:
Bereket Engida
2024-12-18 09:38:57 +03:00
parent 41e895ab07
commit 80b4c42f1d
5 changed files with 10 additions and 11 deletions

View File

@@ -95,13 +95,11 @@ describe("call", async () => {
});
}
if (query.testContext) {
ctx.query = {
message: query.testContext,
};
return {
context: {
// change context
query: {
message: query.testContext,
},
},
context: ctx,
};
}
}),

View File

@@ -1,4 +1,5 @@
import {
APIError,
type Endpoint,
type EndpointResponse,
createEndpointCreator,
@@ -25,7 +26,7 @@ export const createAuthMiddleware = createMiddlewareCreator({
*/
createMiddleware(async () => {
return {} as {
returned?: unknown;
returned?: APIError | Response | Record<string, any>;
endpoint: Endpoint;
};
}),

View File

@@ -55,7 +55,7 @@ export const betterAuth = <O extends BetterAuthOptions>(options: O) => {
user: PrettifyDeep<InferUser<O>>;
};
} & InferPluginTypes<O>,
$ErrorCodes: {
$ERROR_CODES: {
...errorCodes,
...BASE_ERROR_CODES,
} as InferPluginErrorCodes<O> & typeof BASE_ERROR_CODES,

View File

@@ -9,8 +9,8 @@ import type { Ref } from "vue";
import type { ReadableAtom } from "nanostores";
import type { Session } from "../db/schema";
import { BetterFetchError } from "@better-fetch/fetch";
import { passkeyClient, twoFactorClient } from "../plugins";
import { organizationClient } from "./plugins";
import { twoFactorClient } from "../plugins";
import { organizationClient, passkeyClient } from "./plugins";
describe("run time proxy", async () => {
it("proxy api should be called", async () => {

View File

@@ -5,7 +5,7 @@ export type HookEndpointContext<C extends Record<string, any> = {}> =
ContextTools & {
context: AuthContext &
C & {
returned: APIError | Response | Record<string, any>;
returned?: APIError | Response | Record<string, any>;
};
} & {
body: any;