chore: add mysql demo

This commit is contained in:
Bereket Engida
2024-11-16 11:50:00 +03:00
parent be9a734b59
commit 39c7643ef5
3 changed files with 201 additions and 229 deletions

View File

@@ -15,6 +15,7 @@ import { reactResetPasswordEmail } from "./email/rest-password";
import { resend } from "./email/resend";
import { MysqlDialect } from "kysely";
import { createPool } from "mysql2/promise";
import { nextCookies } from "better-auth/next-js";
const from = process.env.BETTER_AUTH_EMAIL || "delivered@resend.dev";
const to = process.env.TEST_EMAIL || "";
@@ -25,13 +26,15 @@ const libsql = new LibsqlDialect({
});
const mysql = new MysqlDialect(
createPool("mysql://user:password@localhost:3306/better_auth"),
createPool(process.env.MYSQL_DATABASE_URL || ""),
);
const dialect = process.env.USE_MYSQL ? mysql : libsql;
export const auth = betterAuth({
appName: "Better Auth Demo",
database: {
dialect: mysql,
dialect,
type: "mysql",
},
session: {
@@ -141,5 +144,6 @@ export const auth = betterAuth({
multiSession(),
oneTap(),
oAuthProxy(),
nextCookies(),
],
});