naystack - v1.9.9
    Preparing search index...

    Type Alias SetupEmailAuthOptions

    Options for initializing email auth routes (GET/POST/PUT/DELETE) via setupEmailAuth.

    const options: SetupEmailAuthOptions = {
    getUser: async ({ email }) => db.query.users.findFirst({ where: eq(users.email, email) }),
    createUser: async (data) => (await db.insert(users).values(data).returning())[0],
    onSignUp: async (userId, body) => { console.log("New user:", userId); },
    };
    type SetupEmailAuthOptions = {
        allowedOrigins?: string[];
        createUser: (user: any) => Promise<UserOutput | undefined>;
        getUser: (data: any) => Promise<UserOutput | undefined>;
        onError?: ErrorHandler;
        onLogin?: (userId: number | null, body: any) => Promise<void>;
        onLogout?: (userId: number | null, body: any) => Promise<void>;
        onRefresh?: (userId: number | null, body: any) => Promise<void>;
        onSignUp?: (userId: number | null, body: any) => Promise<void>;
    }
    Index

    Properties

    allowedOrigins?: string[]

    Optional list of allowed CORS origins. If set, cross-origin requests from unlisted origins are rejected with 403.

    createUser: (user: any) => Promise<UserOutput | undefined>

    Creates a new user with the hashed password; returns the created user as UserOutput.

    getUser: (data: any) => Promise<UserOutput | undefined>

    Fetches user by request data (e.g. { email }); used for login and sign-up duplicate check. Must return a UserOutput or undefined.

    onError?: ErrorHandler

    Optional custom handler for validation/auth errors; return a NextResponse to override default error responses.

    onLogin?: (userId: number | null, body: any) => Promise<void>

    Optional callback after successful login. Receives (userId, requestBody).

    onLogout?: (userId: number | null, body: any) => Promise<void>

    Optional callback when DELETE logout is used. Receives (userId, requestBody).

    onRefresh?: (userId: number | null, body: any) => Promise<void>

    Optional callback when GET refresh is used. Receives (userId, requestBody).

    onSignUp?: (userId: number | null, body: any) => Promise<void>

    Optional callback after successful sign-up. Receives (userId, requestBody).