refactor: simplify auth component configuration

- Removed the local schema configuration from the auth component, streamlining the integration with Better Auth.
- Updated the client creation to focus solely on the DataModel, enhancing clarity and maintainability.
This commit is contained in:
2025-11-07 09:18:41 -03:00
parent ca51839082
commit 6f4df44a00

View File

@@ -4,20 +4,21 @@ import { components } from "./_generated/api";
import { type DataModel } from "./_generated/dataModel"; import { type DataModel } from "./_generated/dataModel";
import { query } from "./_generated/server"; import { query } from "./_generated/server";
import { betterAuth } from "better-auth"; import { betterAuth } from "better-auth";
import authSchema from "./betterAuth/schema"; // import authSchema from "./betterAuth/schema";
const siteUrl = process.env.SITE_URL!; const siteUrl = process.env.SITE_URL!;
// The component client has methods needed for integrating Convex with Better Auth, // The component client has methods needed for integrating Convex with Better Auth,
// as well as helper methods for general use. // as well as helper methods for general use.
export const authComponent = createClient<DataModel, typeof authSchema>( export const authComponent = createClient<DataModel>(components.betterAuth);
components.betterAuth, // export const authComponent = createClient<DataModel, typeof authSchema>(
{ // components.betterAuth,
local: { // {
schema: authSchema, // local: {
}, // schema: authSchema,
} // },
); // }
// );
export const createAuth = ( export const createAuth = (
ctx: GenericCtx<DataModel>, ctx: GenericCtx<DataModel>,