-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from AnkanSaha/dev
Dev
- Loading branch information
Showing
4 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
} | ||
} |