Function initLRPC

  • This function is used to initialize the LRPC engine

    Parameters

    • config: {
          app: Express;
          application: string;
          authorize?: (
              token: string,
              path: string,
              role: string[],
          ) => Promise<{ data: any; message: string; status: Status }>;
          corsConfig?: {
              allowedHeaders?: string | string[];
              credentials?: boolean;
              exposedHeaders?: string | string[];
              maxAge?: number;
              methods?: string | string[];
              origin?: string | boolean | RegExp | (string | boolean | RegExp)[];
          };
          isGateway?: boolean;
          oauthAuthorize?: (
              request: Request,
              path: string,
              decoded: any,
          ) => Promise<{ message: string; status: Status }>;
          service: string;
      }

      The configuration object

      • app: Express

        The express app

      • application: string

        The application name

      • Optionalauthorize?: (
            token: string,
            path: string,
            role: string[],
        ) => Promise<{ data: any; message: string; status: Status }>
      • OptionalcorsConfig?: {
            allowedHeaders?: string | string[];
            credentials?: boolean;
            exposedHeaders?: string | string[];
            maxAge?: number;
            methods?: string | string[];
            origin?: string | boolean | RegExp | (string | boolean | RegExp)[];
        }

        The cors configuration

      • OptionalisGateway?: boolean

        Whether the service is a gateway or not

      • OptionaloauthAuthorize?: (
            request: Request,
            path: string,
            decoded: any,
        ) => Promise<{ message: string; status: Status }>
      • service: string

        The service name

    • Optionalcontrollers: any

      Local controllers

    • OptionalserviceClients: any

      other services controllers

    • OptionalContainer: any

      Dependency injection container

    • OptionalsocketConfig: {
          onConnection: (socketServer: any, socketClient: any) => Promise<void>;
          onDisconnection: (
              socketServer: any,
              socketClient: any,
              data: any,
          ) => Promise<void>;
      }

      socket config

    Returns LRPCEngine

    The LRPCEngine instance