chore: perauset customer project

This commit is contained in:
e2e
2026-07-11 08:54:43 +02:00
commit 49d05dfa0b
293 changed files with 28421 additions and 0 deletions

20
apps/app/src/lib/auth.ts Normal file
View File

@@ -0,0 +1,20 @@
import { createAuthClient } from 'better-auth/client'
import { apiUrl } from './env'
// Better Auth mounts at /api/auth (default basePath); the client appends the
// endpoint verbatim to baseURL, so the base must include /auth — otherwise it
// emits /api/sign-in/email and 404s on both sandbox and deploy.
export const authClient = createAuthClient({
baseURL: `${apiUrl()}/auth`,
})
export const INVALID_CREDENTIALS = 'INVALID_CREDENTIALS'
export async function signIn(email: string, password: string): Promise<void> {
const { error } = await authClient.signIn.email({ email, password })
if (error) throw new Error(INVALID_CREDENTIALS)
}
export async function signOut(): Promise<void> {
await authClient.signOut()
}