chore: add .env.exmaple on examples

This commit is contained in:
Bereket Engida
2024-10-14 20:06:03 +03:00
parent 256c8ca5ed
commit 2bc21748e7
75 changed files with 796 additions and 1225 deletions

View File

@@ -1,37 +1,45 @@
import { betterAuth } from "better-auth";
import { organization, passkey, twoFactor } from "better-auth/plugins";
import {
bearer,
organization,
passkey,
twoFactor,
admin,
} from "better-auth/plugins";
import { reactInvitationEmail } from "./email/invitation";
import { LibsqlDialect } from "@libsql/kysely-libsql";
import { reactResetPasswordEmail } from "./email/rest-password";
import { resend } from "./email/resend";
const from = process.env.BETTER_AUTH_EMAIL || "delivered@resend.dev";
const to = process.env.TEST_EMAIL || "";
const libsql = new LibsqlDialect({
url: process.env.TURSO_DATABASE_URL || "",
authToken: process.env.TURSO_AUTH_TOKEN || "",
});
export const auth = betterAuth({
database: {
provider: "sqlite",
url: "./db.sqlite",
dialect: libsql,
type: "sqlite",
},
emailAndPassword: {
enabled: true,
async sendResetPassword(token, user) {
const res = await resend.emails.send({
async sendResetPassword(url, user) {
await resend.emails.send({
from,
to: user.email,
subject: "Reset your password",
react: reactResetPasswordEmail({
username: user.email,
resetLink: `${
process.env.NODE_ENV === "development"
? "http://localhost:3000"
: process.env.NEXT_PUBLIC_APP_URL ||
process.env.VERCEL_URL ||
process.env.BETTER_AUTH_URL
}/reset-password/${token}`,
resetLink: url,
}),
});
},
sendEmailVerificationOnSignUp: true,
async sendVerificationEmail(email, url) {
console.log("Sending verification email to", email);
const res = await resend.emails.send({
from,
to: to || email,
@@ -68,12 +76,19 @@ export const auth = betterAuth({
}),
twoFactor({
otpOptions: {
sendOTP(user, otp) {
console.log({ otp });
async sendOTP(user, otp) {
await resend.emails.send({
from,
to: user.email,
subject: "Your OTP",
html: `Your OTP is ${otp}`,
});
},
},
}),
passkey(),
bearer(),
admin(),
],
socialProviders: {
github: {
@@ -84,5 +99,13 @@ export const auth = betterAuth({
clientId: process.env.GOOGLE_CLIENT_ID || "",
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
},
discord: {
clientId: process.env.DISCORD_CLIENT_ID || "",
clientSecret: process.env.DISCORD_CLIENT_SECRET || "",
},
microsoft: {
clientId: process.env.MICROSOFT_CLIENT_ID || "",
clientSecret: process.env.MICROSOFT_CLIENT_SECRET || "",
},
},
});