fix build env
This commit is contained in:
@@ -5,5 +5,25 @@
|
||||
|
||||
import { auth } from '@pascal-app/auth/server'
|
||||
import { toNextJsHandler } from 'better-auth/next-js'
|
||||
import type { NextRequest } from 'next/server'
|
||||
|
||||
export const { GET, POST } = toNextJsHandler(auth)
|
||||
// Lazy initialization of the handler
|
||||
let handler: ReturnType<typeof toNextJsHandler> | null = null
|
||||
|
||||
function getHandler() {
|
||||
if (!handler) {
|
||||
handler = toNextJsHandler(auth)
|
||||
}
|
||||
return handler
|
||||
}
|
||||
|
||||
// Export route handlers that initialize lazily
|
||||
export async function GET(request: NextRequest) {
|
||||
const { GET: getHandler } = getHandler()
|
||||
return getHandler(request)
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const { POST: postHandler } = getHandler()
|
||||
return postHandler(request)
|
||||
}
|
||||
|
||||
@@ -104,6 +104,22 @@ export const auth = new Proxy({} as ReturnType<typeof betterAuth>, {
|
||||
|
||||
/**
|
||||
* Type helpers for better-auth session
|
||||
* These are generic types that should match Better Auth's session structure
|
||||
*/
|
||||
export type Session = typeof auth.$Infer.Session.session
|
||||
export type User = typeof auth.$Infer.Session.user
|
||||
export type Session = {
|
||||
id: string
|
||||
userId: string
|
||||
activePropertyId?: string | null
|
||||
expiresAt: Date
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
}
|
||||
|
||||
export type User = {
|
||||
id: string
|
||||
email: string
|
||||
emailVerified: boolean
|
||||
name: string
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user