Interface HandlerConfig<T, U>

Endpoint class Handler interface

interface HandlerConfig<T, U> {
    handler: (data: LRPCRequest<T>) => Promise<BaseResponse<U>>;
    onSocket?: (
        id: string,
        status: "connect" | "disconnect" | "message",
        data?: any,
    ) => Promise<void>;
    validator: (input: T) => Promise<{ message: string; status: Status }>;
}

Type Parameters

  • T
  • U

Properties

handler: (data: LRPCRequest<T>) => Promise<BaseResponse<U>>

This endpoint handles the request after validation has occurred Takes in the express request object and returns a response There's a context object wuth type, id, path and permissions The id refers to user Id, path refers to the procedure, The permissions refer to the user's permissions as specified in IPermission interface

Type declaration

onSocket?: (
    id: string,
    status: "connect" | "disconnect" | "message",
    data?: any,
) => Promise<void>

This function is called when the socket is connected, disconnected or message received

Type declaration

    • (
          id: string,
          status: "connect" | "disconnect" | "message",
          data?: any,
      ): Promise<void>
    • Parameters

      • id: string

        The socket id

      • status: "connect" | "disconnect" | "message"

        The status of the socket

      • Optionaldata: any

        The data received

      Returns Promise<void>

validator: (input: T) => Promise<{ message: string; status: Status }>

This function handles request data validation

Type declaration

    • (input: T): Promise<{ message: string; status: Status }>
    • Parameters

      • input: T

        The request payload

      Returns Promise<{ message: string; status: Status }>

      A message and a status