33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { triplitAdapter } from '@daveyplate/better-auth-triplit';
|
|
import { HttpClient } from '@triplit/client';
|
|
import { betterAuth } from 'better-auth/minimal';
|
|
import { schema } from '../triplit/schema';
|
|
|
|
const httpClient = new HttpClient({
|
|
schema,
|
|
serverUrl: process.env.NUXT_PUBLIC_TRIPLIT_URL,
|
|
token: process.env.TRIPLIT_SERVICE_TOKEN,
|
|
});
|
|
|
|
export const auth = betterAuth({
|
|
database: triplitAdapter({
|
|
httpClient,
|
|
secretKey: process.env.BETTER_AUTH_SECRET,
|
|
}),
|
|
|
|
session: {
|
|
cookieCache: {
|
|
enabled: true,
|
|
maxAge: 5 * 60,
|
|
},
|
|
},
|
|
|
|
trustedOrigins: [process.env.NUXT_PUBLIC_URL ?? 'http://localhost:3000'],
|
|
|
|
emailAndPassword: {
|
|
// if DISABLE_LOCAL_AUTH is set to "1" or "true" then local auth is disabled
|
|
enabled: process.env.DISABLE_LOCAL_AUTH?.toLowerCase() !== 'true' && process.env.DISABLE_LOCAL_AUTH !== '1',
|
|
disableSignUp: process.env.DISABLE_SIGNUP?.toLowerCase() === 'true' || process.env.DISABLE_SIGNUP === '1',
|
|
},
|
|
});
|