UNPKG

better-auth

Version:

The most comprehensive authentication framework for TypeScript.

28 lines (26 loc) 1 kB
import { getAuthTables } from "@better-auth/core/db"; import { logger } from "@better-auth/core/env"; //#region src/db/adapter-base.ts async function getBaseAdapter(options, handleDirectDatabase) { let adapter; if (!options.database) { const tables = getAuthTables(options); const memoryDB = Object.keys(tables).reduce((acc, key) => { acc[key] = []; return acc; }, {}); const { memoryAdapter } = await import("../adapters/memory-adapter/index.mjs"); adapter = memoryAdapter(memoryDB)(options); } else if (typeof options.database === "function") adapter = options.database(options); else adapter = await handleDirectDatabase(options); if (!adapter.transaction) { logger.warn("Adapter does not correctly implement transaction function, patching it automatically. Please update your adapter implementation."); adapter.transaction = async (cb) => { return cb(adapter); }; } return adapter; } //#endregion export { getBaseAdapter }; //# sourceMappingURL=adapter-base.mjs.map