naystack - v1.5.10
    Preparing search index...

    Type Alias InitRoutesOptions

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

    const options: InitRoutesOptions = {
    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 InitRoutesOptions = {
        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

    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).