Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | // better-auth
import type { Auth } from 'better-auth';
// better-auth config
import { betterAuthConfig } from '../../auth.config';
// drizzle
import { drizzle } from 'drizzle-orm/node-postgres';
// drizzle schema
import * as schema from '../../db/schema';
// types
import { Bindings } from '../../types';
// auth関数の型定義
export type AuthFactoryType = (env: Bindings) => Auth;
// better-auth setup
export const authFactory = (env: Bindings): Auth => {
// drizzle instance
const db = drizzle(env.HYPERDRIVE.connectionString);
// env variables from bindings
const betterAuthSecret = env.BETTER_AUTH_SECRET;
const betterAuthUrl = env.BETTER_AUTH_URL;
const discordClientId = env.DISCORD_CLIENT_ID;
const discordClientSecret = env.DISCORD_CLIENT_SECRET;
const googleClientId = env.GOOGLE_CLIENT_ID;
const googleClientSecret = env.GOOGLE_CLIENT_SECRET;
// better-auth instance
const betterAuthInstance = betterAuthConfig(
db,
schema,
betterAuthSecret,
betterAuthUrl,
discordClientId,
discordClientSecret,
googleClientId,
googleClientSecret
);
return betterAuthInstance;
};
|