From 54e24dcb6f7b0d8f701a2efd501762d853292871 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 07:29:52 +0000 Subject: [PATCH] style: format code with Prettier and StandardJS This commit fixes the style issues introduced in 06b04cb according to the output from Prettier and StandardJS. Details: https://github.com/AnkanSaha/outers/pull/181 --- README.md | 12 ++++++++++-- source/Cluster/class/CreateClusterByClass.method.ts | 12 ++++++------ .../function/CreateClusterByFunction.method.ts | 10 +++++----- source/Config/Constant/Middleware.Constant.ts | 2 +- source/Middlewares/User Counter/Base.middleware.ts | 4 ++-- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 59a7e07..534fd21 100644 --- a/README.md +++ b/README.md @@ -460,8 +460,13 @@ app.use("/api", Middleware.JWTValidator("FieldName", Token), MainRouter); // use ```javascript const { Middleware } = require("outers"); // import the package -app.use("/api", Middleware.RequestCounter(true, true, true, true, true), MainRouter); // count the number of requests in NodeJS with the Middleware function +app.use( + "/api", + Middleware.RequestCounter(true, true, true, true, true), + MainRouter, +); // count the number of requests in NodeJS with the Middleware function ``` + - Note : You can pass true/false in all parameters of the function, by default it is set to true, if you set it to true then it will count the number of requests in the console - Note : The First Parameter is SaveIP which is used to save the IP Address in the Request Object, by default it is set to true, if you set it to true then it will save the IP Address in the Request Object @@ -470,11 +475,14 @@ app.use("/api", Middleware.RequestCounter(true, true, true, true, true), MainRou - Note : The Third Parameter is SaveRequestTime which is used to save the Request Time in the Request Object, by default it is set to true, if you set it to true then it will save the Request Time in the Request Object -- Note : The Fourth Parameter is SaveContentType which is used to save the Content Type in the Request Object, by default it is set to true, if you set it to true then it will save the Content Type in the Request Object +- Note : The Fourth Parameter is SaveContentType which is used to save the Content Type in the Request Object, by default it is set to true, if you set it to true then it will save the Content Type in the Request Object - Note : The Fifth Parameter is SaveMethod which is used to save the Method in the Request Object, by default it is set to true, if you set it to true then it will save the Method in the Request Object ## License MIT + +``` + ``` diff --git a/source/Cluster/class/CreateClusterByClass.method.ts b/source/Cluster/class/CreateClusterByClass.method.ts index 8c0b1c8..84c0b87 100644 --- a/source/Cluster/class/CreateClusterByClass.method.ts +++ b/source/Cluster/class/CreateClusterByClass.method.ts @@ -46,7 +46,7 @@ export default class CreateClusterByClass { NumberOfWorkers?: number, BeforeListenFunctions?: any[], AfterListenFunctions?: any[], - FunctionMiddlewares?: any[] + FunctionMiddlewares?: any[], ) { this.#ExpressServer = ExpressServer ?? express(); // Express Server Instance this.#PORT = PORT; // Active Server Instance @@ -107,7 +107,7 @@ export default class CreateClusterByClass { 1024 / 1024 / 1024 - ).toFixed(2)} GB Free Ram : ${cpus()[0].model}` + ).toFixed(2)} GB Free Ram : ${cpus()[0].model}`, ); // Create a worker according to the number that is specified @@ -120,7 +120,7 @@ export default class CreateClusterByClass { ClusterConfig.on("online", (worker) => { green(`🚀 Worker ${worker.process.pid} started 🚀`); blue( - `Environment Variables Loaded Successfully in Worker : ${worker.process.pid}` + `Environment Variables Loaded Successfully in Worker : ${worker.process.pid}`, ); this.#GlobalResponseObject.ActiveWorker++; // Increment Active Worker Count by 1 yellow(`Worker ${worker.process.pid} is listening`); @@ -133,7 +133,7 @@ export default class CreateClusterByClass { ClusterConfig.fork(); green(`🚀 Worker ${worker.process.pid} restarted 🚀`); blue( - `Environment Variables Loaded Successfully in Worker : ${worker.process.pid}` + `Environment Variables Loaded Successfully in Worker : ${worker.process.pid}`, ); this.#GlobalResponseObject.ActiveWorker++; // Increment Active Worker Count by 1 yellow(`Worker ${worker.process.pid} is listening`); @@ -143,7 +143,7 @@ export default class CreateClusterByClass { this.#EnableTrustProxy == true ? this.#ExpressServer.set("trust proxy", true) : yellow( - "Trust Proxy is not enabled, if you are working behind a proxy, please enable it to get the real IP Address" + "Trust Proxy is not enabled, if you are working behind a proxy, please enable it to get the real IP Address", ); // Apply Function Middlewares to Express Server Instance like CORS, Body Parser, etc. @@ -182,7 +182,7 @@ export default class CreateClusterByClass { await ListenFunction(); // Run Function one by one } } - } + }, ); // Start Server on Port // Return the Active Server Instance in Response Object diff --git a/source/Cluster/function/CreateClusterByFunction.method.ts b/source/Cluster/function/CreateClusterByFunction.method.ts index 0a8c897..92c7e29 100644 --- a/source/Cluster/function/CreateClusterByFunction.method.ts +++ b/source/Cluster/function/CreateClusterByFunction.method.ts @@ -30,7 +30,7 @@ export default async function Config( EnableTrustProxy: boolean = true, // Enable Trust Proxy BeforeListenFunctions: any[] = [], // Any Functions to run before listen AfterListenFunctions: any[] = [], // Any Functions to run after listen - FunctionMiddlewares: any[] = [] // Any Middlewares to apply + FunctionMiddlewares: any[] = [], // Any Middlewares to apply ): Promise { // Check if User Provided Express Server or not if (!ExpressServer || ExpressServer === undefined) { @@ -68,7 +68,7 @@ export default async function Config( 1024 / 1024 / 1024 - ).toFixed(2)} GB Free Ram : ${cpus()[0].model}` + ).toFixed(2)} GB Free Ram : ${cpus()[0].model}`, ); // Create a worker according to the number that is specified @@ -81,7 +81,7 @@ export default async function Config( ClusterConfig.on("online", (worker) => { green(`🚀 Worker ${worker.process.pid} started 🚀`); blue( - `Environment Variables Loaded Successfully in Worker : ${worker.process.pid}` + `Environment Variables Loaded Successfully in Worker : ${worker.process.pid}`, ); GlobalResponseObject.ActiveWorker++; // Increment Active Worker Count by 1 yellow(`Worker ${worker.process.pid} is listening`); @@ -94,7 +94,7 @@ export default async function Config( ClusterConfig.fork(); green(`🚀 Worker ${worker.process.pid} restarted 🚀`); blue( - `Environment Variables Loaded Successfully in Worker : ${worker.process.pid}` + `Environment Variables Loaded Successfully in Worker : ${worker.process.pid}`, ); GlobalResponseObject.ActiveWorker++; // Increment Active Worker Count by 1 yellow(`Worker ${worker.process.pid} is listening`); @@ -104,7 +104,7 @@ export default async function Config( EnableTrustProxy ? ExpressServer.set("trust proxy", () => true) : yellow( - "Trust Proxy is not enabled, if you are working behind a proxy, please enable it to get the real IP Address" + "Trust Proxy is not enabled, if you are working behind a proxy, please enable it to get the real IP Address", ); // Apply Function Middlewares to Express Server Instance like CORS, Body Parser, etc. diff --git a/source/Config/Constant/Middleware.Constant.ts b/source/Config/Constant/Middleware.Constant.ts index 80742fb..65e9f05 100644 --- a/source/Config/Constant/Middleware.Constant.ts +++ b/source/Config/Constant/Middleware.Constant.ts @@ -128,4 +128,4 @@ export const IPAllowedMethods = ["PUT", "POST", "PATCH", "DELETE"]; // Allowed M export const AllowedMethods = [...IPAllowedMethods, "OPTIONS"]; // Allowed Methods // Constants for Request Counter Storage -export const TodayDate = new Date().toLocaleDateString(); // Get Today's Date \ No newline at end of file +export const TodayDate = new Date().toLocaleDateString(); // Get Today's Date diff --git a/source/Middlewares/User Counter/Base.middleware.ts b/source/Middlewares/User Counter/Base.middleware.ts index db30fe1..83238c8 100644 --- a/source/Middlewares/User Counter/Base.middleware.ts +++ b/source/Middlewares/User Counter/Base.middleware.ts @@ -8,7 +8,7 @@ import { Serve } from "../../Config/outer"; // Importing Serve export const StorageInstance = new Storage( "Request-Counter-details-for-nodejs", 999999, // 999999 MB = 1TB - "Request-Counter-details-for-nodejs" + "Request-Counter-details-for-nodejs", ); // Main middleware function @@ -17,7 +17,7 @@ export default function ( SaveUserAgent: boolean = true, SaveRequestTime: boolean = true, SaveContentType: boolean = true, - SaveMethod: boolean = true + SaveMethod: boolean = true, ) { return async (Request: Request, Response: Response, Next: NextFunction) => { const GetPreviousData = await StorageInstance.Get(TodayDate); // Get previous data