33 lines
901 B
TypeScript
33 lines
901 B
TypeScript
|
|
import { betterAuth } from 'better-auth';
|
||
|
|
import { kyselyAdapter } from '@better-auth/kysely-adapter';
|
||
|
|
import { Kysely, PostgresDialect } from 'kysely';
|
||
|
|
import { Pool } from 'pg';
|
||
|
|
|
||
|
|
const db = new Kysely({
|
||
|
|
dialect: new PostgresDialect({
|
||
|
|
pool: new Pool({
|
||
|
|
connectionString: process.env.DATABASE_URL ||
|
||
|
|
'postgresql://labwise:labwise_dev_pw@localhost:5432/labwise_db',
|
||
|
|
}),
|
||
|
|
}),
|
||
|
|
});
|
||
|
|
|
||
|
|
export const auth = betterAuth({
|
||
|
|
database: kyselyAdapter(db, { type: 'postgres' }),
|
||
|
|
|
||
|
|
baseURL: process.env.BETTER_AUTH_URL || 'http://localhost:3001',
|
||
|
|
secret: process.env.BETTER_AUTH_SECRET || 'dev-secret-change-in-production-min32chars!!',
|
||
|
|
|
||
|
|
socialProviders: {
|
||
|
|
google: {
|
||
|
|
clientId: process.env.GOOGLE_CLIENT_ID || '',
|
||
|
|
clientSecret: process.env.GOOGLE_CLIENT_SECRET || '',
|
||
|
|
},
|
||
|
|
},
|
||
|
|
|
||
|
|
trustedOrigins: [
|
||
|
|
'http://localhost:5173',
|
||
|
|
'https://labwise.wahwa.com',
|
||
|
|
],
|
||
|
|
});
|