export function initAuth(options: {
baseUrl: string;
productionUrl: string;
secret: string | undefined;
}) {
const config = {
user: {
additionalFields: {
firstName: {
type: "string",
required: true,
},
lastName: {
type: "string",
required: true,
},
},
},
database: drizzleAdapter(db, {
provider: "mysql",
}),
baseURL: options.baseUrl,
secret: options.secret,
plugins: [expo()],
emailAndPassword: {
enabled: true,
password: {
hash: async (password: string) => {
return await bcrypt.hash(password, 8);
},
verify: async (data: { hash: string; password: string }) => {
return bcrypt.compare(data.password, data.hash);
},
},
},
trustedOrigins: ["expo://"],
} satisfies BetterAuthOptions;
return betterAuth(config);
}
export type Auth = ReturnType<typeof initAuth>;
export function initAuth(options: {
baseUrl: string;
productionUrl: string;
secret: string | undefined;
}) {
const config = {
user: {
additionalFields: {
firstName: {
type: "string",
required: true,
},
lastName: {
type: "string",
required: true,
},
},
},
database: drizzleAdapter(db, {
provider: "mysql",
}),
baseURL: options.baseUrl,
secret: options.secret,
plugins: [expo()],
emailAndPassword: {
enabled: true,
password: {
hash: async (password: string) => {
return await bcrypt.hash(password, 8);
},
verify: async (data: { hash: string; password: string }) => {
return bcrypt.compare(data.password, data.hash);
},
},
},
trustedOrigins: ["expo://"],
} satisfies BetterAuthOptions;
return betterAuth(config);
}
export type Auth = ReturnType<typeof initAuth>;