chore: remove unused code from context (#536)

This commit is contained in:
Jani
2024-11-15 12:20:57 +01:00
committed by GitHub
parent 93a49c58b4
commit fb37bb1aa7
4 changed files with 3 additions and 15 deletions

View File

@@ -50,7 +50,6 @@ exports[`init > should match config 1`] = `
},
"baseURL": "http://localhost:3000/api/auth",
"createAuthCookie": [Function],
"db": Kysely {},
"internalAdapter": {
"createAccount": [Function],
"createOAuthUser": [Function],

View File

@@ -1,6 +1,4 @@
import type { Kysely } from "kysely";
import { getAuthTables } from "./db/get-tables";
import { createKyselyAdapter } from "./adapters/kysely-adapter/dialect";
import { getAdapter } from "./db/utils";
import { hashPassword, verifyPassword } from "./crypto/password";
import { createInternalAdapter } from "./db";
@@ -30,7 +28,6 @@ export const init = async (options: BetterAuthOptions) => {
const plugins = options.plugins || [];
const internalPlugins = getInternalPlugins(options);
const { kysely: db } = await createKyselyAdapter(options);
const baseURL = getBaseURL(options.baseURL, options.basePath);
const secret =
@@ -103,7 +100,6 @@ export const init = async (options: BetterAuthOptions) => {
logger: createLogger({
disabled: options.logger?.disabled || false,
}),
db,
uuid: generateId,
secondaryStorage: options.secondaryStorage,
password: {
@@ -134,7 +130,6 @@ export type AuthContext = {
socialProviders: OAuthProvider[];
authCookies: BetterAuthCookies;
logger: ReturnType<typeof createLogger>;
db: Kysely<any> | null;
rateLimit: {
enabled: boolean;
window: number;

View File

@@ -297,7 +297,7 @@ export const getOrgAdapter = (
/**
* @requires db
*/
findFullOrganization: async (organizationId: string, db?: Kysely<any>) => {
findFullOrganization: async (organizationId: string) => {
const [org, invitations, members] = await Promise.all([
adapter.findOne<Organization>({
model: "organization",

View File

@@ -241,10 +241,7 @@ export const getFullOrganization = createAuthEndpoint(
});
}
const adapter = getOrgAdapter(ctx.context, ctx.context.orgOptions);
const organization = await adapter.findFullOrganization(
organizationId,
ctx.context.db || undefined,
);
const organization = await adapter.findFullOrganization(organizationId);
if (!organization) {
throw new APIError("BAD_REQUEST", {
message: "Organization not found",
@@ -293,10 +290,7 @@ export const setActiveOrganization = createAuthEndpoint(
});
}
await adapter.setActiveOrganization(session.session.id, organizationId);
const organization = await adapter.findFullOrganization(
organizationId,
ctx.context.db || undefined,
);
const organization = await adapter.findFullOrganization(organizationId);
return ctx.json(organization);
},
);