mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-06-27 16:45:42 -04:00
32 lines
893 B
TypeScript
32 lines
893 B
TypeScript
import { env } from "@/lib/env";
|
|
import { betterAuth, type BetterAuthOptions } from "better-auth";
|
|
import { nextCookies } from "better-auth/next-js";
|
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
import { db } from "@/lib/db";
|
|
import * as schema from "@/lib/db/schema";
|
|
|
|
export const auth = betterAuth({
|
|
baseURL: env.NEXT_PUBLIC_BASE_URL,
|
|
database: drizzleAdapter(db, {
|
|
provider: "pg",
|
|
schema,
|
|
}),
|
|
plugins: [nextCookies()],
|
|
socialProviders: {
|
|
github: {
|
|
clientId: env.AUTH_GITHUB_CLIENT_ID,
|
|
clientSecret: env.AUTH_GITHUB_CLIENT_SECRET,
|
|
scope: ["read:user"],
|
|
disableDefaultScope: true,
|
|
mapProfileToUser(profile) {
|
|
return {
|
|
name: profile.login,
|
|
email: profile.email,
|
|
emailVerified: true,
|
|
image: profile.avatar_url,
|
|
};
|
|
},
|
|
},
|
|
},
|
|
} satisfies BetterAuthOptions);
|