Class LRPCEngine

This class is the main class of the LRPC library

Constructors

Properties

authorize: (
    token: string,
    role: string[],
) => { data?: any; message: string; status: Status }

This function authorizes the user based on the token and roles

Type declaration

    • (token: string, role: string[]): { data?: any; message: string; status: Status }
    • Parameters

      • token: string

        The token to authorize

      • role: string[]

        The roles to authorize

      Returns { data?: any; message: string; status: Status }

      The authorization response

clientHandlers: { [key: string]: Function }

The callback handlers for serviceClient endpoints

handlers: { [key: string]: string }

The callback handler Object for endpoints

initSocket: (server: any) => void

This function initializes the socket server

Type declaration

    • (server: any): void
    • Parameters

      • server: any

        The socket server

      Returns void

invokeEvent: (path: any, data: any) => Promise<void>
isLocal: (key: string) => boolean

This function checks if the procedure is local or not

Type declaration

    • (key: string): boolean
    • Parameters

      • key: string

        The key to check

      Returns boolean

      True if the key is local, false otherwise

processClientControllers: () => Promise<void>

This function processes service client controllers

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

      A promise that resolves when the client controllers are processed

processControllers: () => Promise<void>

This function processes the local controllers

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

      A promise that resolves when the controllers are processed

processQueueRequest: () => Promise<void>

This function processes the rmq request

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

      A promise that resolves when the queue request is processed

processRequest: (req: Request, res: Response) => Promise<void>

This function processes http requests

Type declaration

    • (req: Request, res: Response): Promise<void>
    • Parameters

      • req: Request

        The http request

      • res: Response

        The http response

      Returns Promise<void>

      A promise that resolves when the request is processed

Queue: RabbitMq

The RabbitMq instance

redis: Redis

The Redis instance

registerCallback: (methodKey: string, className: string) => Promise<void>
service: string

The service name of the service

tId: string

The thread Id of the service for multithreaded services

url: string

The url of the service

instance: LRPCEngine

The static instance of the LRPCEngine

trackInstance: number

Tracks the number of instances of the LRPCEngine to limit the number of instances

Methods

  • This function disconnects a socket

    Parameters

    • id: string

      The socket id

    Returns void

  • This function sends a message to a socket

    Parameters

    • id: string

      The socket id

    • data: any

      The data to send

    Returns void

  • Parameters

    • func: Function

    Returns string[]