UNPKG

better-auth

Version:

The most comprehensive authentication framework for TypeScript.

1 lines 1.53 kB
{"version":3,"file":"init-minimal.mjs","names":[],"sources":["../../src/context/init-minimal.ts"],"sourcesContent":["import type { BetterAuthOptions } from \"@better-auth/core\";\nimport { BetterAuthError } from \"@better-auth/core/error\";\nimport { getBaseAdapter } from \"../db\";\nimport { createAuthContext } from \"./create-context\";\n\nexport const initMinimal = async (options: BetterAuthOptions) => {\n\tconst adapter = await getBaseAdapter(options, async () => {\n\t\tthrow new BetterAuthError(\n\t\t\t\"Direct database connection requires Kysely. Please use `better-auth` instead of `better-auth/minimal`, or provide an adapter (drizzleAdapter, prismaAdapter, etc.)\",\n\t\t);\n\t});\n\n\t// Without Kysely, we can't detect database type, so always return \"unknown\"\n\tconst getDatabaseType = (_database: BetterAuthOptions[\"database\"]) =>\n\t\t\"unknown\";\n\n\t// Use base context creation\n\tconst ctx = await createAuthContext(adapter, options, getDatabaseType);\n\n\t// Add runMigrations that throws error (migrations require Kysely)\n\tctx.runMigrations = async function () {\n\t\tthrow new BetterAuthError(\n\t\t\t\"Migrations are not supported in 'better-auth/minimal'. Please use 'better-auth' for migration support.\",\n\t\t);\n\t};\n\n\treturn ctx;\n};\n"],"mappings":";;;;;;AAKA,MAAa,cAAc,OAAO,YAA+B;CAChE,MAAM,UAAU,MAAM,eAAe,SAAS,YAAY;AACzD,QAAM,IAAI,gBACT,qKACA;GACA;CAGF,MAAM,mBAAmB,cACxB;CAGD,MAAM,MAAM,MAAM,kBAAkB,SAAS,SAAS,gBAAgB;AAGtE,KAAI,gBAAgB,iBAAkB;AACrC,QAAM,IAAI,gBACT,yGACA;;AAGF,QAAO"}