@@ -2,7 +2,7 @@ import { stripe } from "@better-auth/stripe"
22import { MembershipRepository } from "@domain/organizations"
33import { UserId , generateId } from "@domain/shared"
44import { MembershipRepositoryLive , SqlClientLive } from "@platform/db-postgres"
5- import { type PostgresClient , type PostgresDb , postgresSchema } from "@platform/db-postgres"
5+ import { type PostgresClient , postgresSchema } from "@platform/db-postgres"
66import { parseEnv , parseEnvOptional } from "@platform/env"
77import { betterAuth } from "better-auth"
88import { drizzleAdapter } from "better-auth/adapters/drizzle"
@@ -26,7 +26,7 @@ import Stripe from "stripe"
2626 */
2727
2828export interface BetterAuthConfig {
29- readonly db : PostgresDb
29+ readonly client : PostgresClient
3030 readonly baseUrl ?: string
3131 readonly secret ?: string
3232 readonly googleClientId ?: string
@@ -102,12 +102,11 @@ export const createBetterAuth = (config: BetterAuthConfig) => {
102102 const activeOrganizationIdInSession = "activeOrganizationId" in session ? session . activeOrganizationId : null
103103 if ( activeOrganizationIdInSession ) return { user, session }
104104
105- const mockClient = { db : config . db } as PostgresClient
106105 const memberships = await Effect . runPromise (
107106 Effect . gen ( function * ( ) {
108107 const repo = yield * MembershipRepository
109108 return yield * repo . findByUserId ( UserId ( user . id ) )
110- } ) . pipe ( Effect . provide ( MembershipRepositoryLive ) , Effect . provide ( SqlClientLive ( mockClient ) ) ) ,
109+ } ) . pipe ( Effect . provide ( MembershipRepositoryLive ) , Effect . provide ( SqlClientLive ( config . client ) ) ) ,
111110 )
112111 const activeOrganizationId = memberships [ 0 ] ?. organizationId
113112
@@ -177,7 +176,7 @@ export const createBetterAuth = (config: BetterAuthConfig) => {
177176 }
178177
179178 return betterAuth ( {
180- database : drizzleAdapter ( config . db , {
179+ database : drizzleAdapter ( config . client . db , {
181180 provider : "pg" ,
182181 schema : {
183182 user : postgresSchema . user ,
@@ -212,6 +211,7 @@ export const createBetterAuth = (config: BetterAuthConfig) => {
212211 } ,
213212 } ) ,
214213 } ,
214+ // TODO: review
215215 // Email/password enabled for CLI authentication
216216 // Note: Email verification disabled for MVP - will be enabled in Phase 2
217217 emailAndPassword : {
0 commit comments