Skip to content

Commit 8f41602

Browse files
📝 Add docstrings to claude/issue-27-20250629_142659
Docstrings generation was requested by @jaspermayone. * #112 (comment) The following files were modified: * `src/func/domain/domain.ts` * `src/func/domain/parseData.ts`
1 parent de99842 commit 8f41602

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

src/func/domain/domain.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ import { db } from "src/utils/db";
1818
import { warn } from "src/utils/logger";
1919

2020
/**
21-
* Helper function to safely call an external API service with quota error handling
22-
* @param serviceName - Name of the service for logging
23-
* @param serviceCall - Promise function to call the service
24-
* @param domain - Domain being checked (for logging)
25-
* @returns Service response or null if failed
21+
* Executes an external service call for a domain, returning the result or `null` if an error occurs.
22+
*
23+
* Handles quota and rate limit errors gracefully by logging a warning and skipping the service check, allowing the overall process to continue without interruption.
24+
*
25+
* @param serviceName - The name of the external service being called, used for logging context.
26+
* @param serviceCall - A function that returns a Promise for the external service request.
27+
* @param domain - The domain being checked, included in log messages for context.
28+
* @returns The service response if successful, or `null` if an error or quota limit is encountered.
2629
*/
2730
async function safeServiceCall(
2831
serviceName: string,
@@ -57,9 +60,12 @@ async function safeServiceCall(
5760
}
5861

5962
/**
60-
* Check the domain against all the services
61-
* @param domain - Domain to check
62-
* @returns void
63+
* Performs security and reputation checks on a domain using multiple external services.
64+
*
65+
* Calls a set of external services to assess the given domain, handling errors gracefully for each service. Ensures the domain is recorded in the database if not already present.
66+
*
67+
* @param domain - The domain name to check
68+
* @returns An object containing the results from each service, with `null` for any service that failed or was rate-limited
6369
*/
6470
export async function domainCheck(domain: string) {
6571
const tsStart = Date.now();

src/func/domain/parseData.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
/**
2-
* parses the data from the different sources and returns a boolean value
3-
* @param walshyData - Data from Walshy API
4-
* @param ipQualityScoreData - Data from IPQualityScore API
5-
* @param googleSafebrowsingData - Data from Google Safebrowsing API
6-
* @param sinkingYahtsData - Data from Sinking Yahts API
7-
* @param virusTotalData - Data from VirusTotal API
8-
* @param phishObserverData - Data from PhishObserver API
9-
* @param urlScanData - Data from URLScan API
10-
* @param securitytrailsData - Data from SecurityTrails API
11-
* @param phishreportData - Data from Phishreport API
12-
* @param abuseChData - Data from AbuseCh API
13-
* @returns boolean
14-
**/
2+
* Aggregates results from multiple security data sources to determine if a domain is malicious or unsafe.
3+
*
4+
* Evaluates input from various APIs and returns `true` if any source indicates the domain is potentially harmful; otherwise, returns `false`.
5+
*
6+
* @returns `true` if any data source flags the domain as malicious or unsafe; otherwise, `false`.
7+
*/
158
export async function parseData(
169
walshyData: any,
1710
ipQualityScoreData: any,

0 commit comments

Comments
 (0)