Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,6 @@ export default defineNuxtModule<BetterAuthModuleOptions>({
const hasNuxtHub = hasNuxtModule('@nuxthub/core', nuxt)
const hub = hasNuxtHub ? (nuxt.options as { hub?: NuxtHubOptions }).hub : undefined
const hasHubDbAvailable = !clientOnly && hasNuxtHub && !!hub?.db
const deprecatedProvider = (options as { database?: { provider?: string } }).database?.provider
if (deprecatedProvider) {
throw new Error(
`[nuxt-better-auth] auth.database.provider has been removed. Remove auth.database.provider="${deprecatedProvider}". To configure a database, either set "database" directly in server/auth.config.ts (defineServerAuth) or install a provider module that registers better-auth:database:providers.`,
)
}

let databaseProvider: ModuleDatabaseProviderId = 'none'
let hasHubDb = false

Expand Down
10 changes: 4 additions & 6 deletions src/schema-generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { DBAdapter } from '@better-auth/cli/api'
import type { BetterAuthOptions } from 'better-auth'
import { generateDrizzleSchema as _generateDrizzleSchema } from '@better-auth/cli/api'
import { consola } from 'consola'
Expand All @@ -8,6 +7,7 @@ export interface SchemaOptions { usePlural?: boolean, useUuid?: boolean, casing?

type Dialect = 'sqlite' | 'postgresql' | 'mysql'
type Provider = 'sqlite' | 'pg' | 'mysql'
type DrizzleSchemaInput = Parameters<typeof _generateDrizzleSchema>[0]

// Minimal interface matching what _generateDrizzleSchema actually uses from adapter
interface SchemaGeneratorAdapter {
Expand Down Expand Up @@ -42,12 +42,10 @@ export async function generateDrizzleSchema(authOptions: BetterAuthOptions, dial
},
}

// @better-auth/cli may resolve a different @better-auth/core type instance in monorepos/workspaces.
// Cast to the callee's parameter type to avoid nominal-type incompatibilities across identical versions.
const result = await _generateDrizzleSchema({
adapter: adapter as unknown as DBAdapter,
options,
} as unknown as Parameters<typeof _generateDrizzleSchema>[0])
adapter: adapter as unknown as DrizzleSchemaInput['adapter'],
options: options as unknown as DrizzleSchemaInput['options'],
})
if (!result.code) {
throw new Error(`Schema generation returned empty result for ${dialect}`)
}
Expand Down
Loading