outers
Version:
outers - a all in one package for your day to day use
23 lines (22 loc) • 1.32 kB
TypeScript
import { Express } from "express";
import { ResponseObject } from "../../Config/Interfaces/Cluster/CreateClusterByFunction.interfaces";
/**
* Configures and creates a cluster by function.
*
* @param ExpressServer - The main Express server instance.
* @param PORT - The port number to listen on.
* @param NumberOfWorkers - The number of worker copies to create.
* @param EnableTrustProxy - Whether to enable trust proxy or not.
* @param BeforeListenFunctions - Any functions to run before listening.
* @param AfterListenFunctions - Any functions to run after listening.
* @param FunctionMiddlewares - Any middlewares to apply to the Express server instance.
* @returns The response object containing the active server instance, active worker count, and responses from before listen functions.
* @throws Error if Express server, port, or number of workers is not provided.
*/
export default function Config(ExpressServer?: Express, // Main Express Server Instance
PORT?: number, // Port Number to Listen
NumberOfWorkers?: number, // Number of Copies of Workers
EnableTrustProxy?: boolean, // Enable Trust Proxy
BeforeListenFunctions?: any[], // Any Functions to run before listen
AfterListenFunctions?: any[], // Any Functions to run after listen
FunctionMiddlewares?: any[]): Promise<ResponseObject | undefined>;