outers
Version:
outers - a all in one package for your day to day use
62 lines (61 loc) • 2.64 kB
TypeScript
import { Express } from "express";
import { WebSocketServer } from "ws";
import { ResponseObject } from "../../Config/Interfaces/Cluster/CreateClusterByFunction.interfaces";
/**
* Represents a class for creating a SocketCluster cluster.
*/
export default class createSocketCluster {
#private;
/**
* Creates an instance of CreateClusterByClass.
* @param ExpressServer - Express Server Instance.
* @param PORT - Port Number to Listen.
* @param NumberOfWorkers - Number of Copies of Workers.
* @param BeforeListenFunctions - Any Functions to run before listen.
* @param AfterListenFunctions - Any Functions to run after listen.
* @param FunctionMiddlewares - Any Middlewares to apply.
* @param EnableTrustProxy - Enable Trust Proxy.
*/
constructor(ExpressServer: Express, PORT: number, NumberOfWorkers?: number, BeforeListenFunctions?: any[], AfterListenFunctions?: any[], FunctionMiddlewares?: any[], EnableTrustProxy?: boolean);
/**
* Starts the server.
* @returns A Promise that resolves to the ResponseObject or undefined.
* @throws Error if Express Server or Port is not provided.
*/
StartServer(): Promise<ResponseObject | undefined>;
/**
* Gets the WebSocket connection handler.
* @returns The WebSocket connection handler or null.
*/
getWebSocketConnectionHandler(): WebSocketServer;
/**
* Sets the number of workers.
* @param NumberOfWorkers - The number of workers.
* @throws Error if NumberOfWorkers is not provided, not a number, or not a positive number.
*/
SetNumberOfWorkers(NumberOfWorkers: number): void;
/**
* Adds a function to run before listen.
* @param FunctionToRun - The function to run before listen.
* @throws Error if FunctionToRun is not provided or not a function.
*/
AddBeforeListenFunction(FunctionToRun: Function): void;
/**
* Adds a function to run after listen.
* @param FunctionToRun - The function to run after listen.
* @throws Error if FunctionToRun is not provided or not a function.
*/
AddAfterListenFunction(FunctionToRun: Function): void;
/**
* Adds a middleware function.
* @param FunctionToRun - The middleware function to add.
* @throws Error if FunctionToRun is not provided or not a function.
*/
AddMiddleware(FunctionToRun: Function): void;
/**
* Sets the status of the Trust Proxy.
* @param Status - The status of the Trust Proxy.
* @throws Error if Status is not provided or not a boolean.
*/
SetEnableTrustProxy(Status: boolean): void;
}