Skip to content

Commit

Permalink
Merge pull request #182 from AnkanSaha/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AnkanSaha committed Mar 8, 2024
2 parents 46950c9 + 6b92e2c commit 85756df
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "outers",
"version": "8.3.0",
"version": "8.3.1",
"description": "outers - a all in one package for your day to day use",
"main": "./lib/Config/outer.js",
"types": "./lib/Config/outer.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions source/Config/outer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import RequestCounter from "../Middlewares/User Counter/Base.middleware"; // Imp
// Import Functions Related Modules
import IPChecker from "../Functions/IP Type Checker.function"; // Import IP Type Checker Module
import getIPDetails from "../Functions/Get IP Details.function"; // Import Get IP Details Module
import ReadRequestCount from "../Functions/Read Request Count"; // Import Read Request Count Module

// Export Console Color Related Modules
export const Console = Object.freeze({
Expand Down Expand Up @@ -154,4 +155,5 @@ export const FunctionBased = Object.freeze({
PUT: PutFetch, // Export Put Fetch Module
DELETE: DeleteFetch, // Export Delete
},
ReadRequestCount, // Export Read Request Count Module
}); // Export
36 changes: 36 additions & 0 deletions source/Functions/Read Request Count.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { StorageInstance } from "../Middlewares/User Counter/Base.middleware"; // Import The Storage for Read Request Count

// Interface for Read Request Count
interface ReturnData {
status: number;
message: string;
Data: any[];
TotalData: number;
}

// Main Function
/**
* Retrieves the request count from the storage.
* If a RequestDate is provided, retrieves the request count for that specific date.
* If no RequestDate is provided, retrieves the overall request count.
* @param {string} RequestDate - The date for which to retrieve the request count. If not provided, retrieves the overall request count.
* @param {string} RequestDate - The Date Must Be M/D/YYYY format. like : 3/8/2024
* @returns {Promise<number>} - A promise that resolves to the request count.
* @throws {Error} - If unable to read the request count from the storage.
*/
export default async function (RequestDate: string): Promise<ReturnData> {
try {
if (
RequestDate === undefined ||
RequestDate === null ||
RequestDate === ""
) {
return await StorageInstance.Get(); // Get All Data in Storage File
} else {
return await StorageInstance.Get(RequestDate);
}
} catch (error) {
throw new Error("Unable to read the request count from the storage.");
}
}

0 comments on commit 85756df

Please sign in to comment.