From b36db727890999156f3ff4c1ef04f4d382bced4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kh=C3=A1nh=20Ho=C3=A0ng?= Date: Fri, 1 Mar 2024 17:26:22 +0700 Subject: [PATCH] docs(lookup): add example to lookup function and comment to configs file Added an example and detailed parameters to the `findThreadMatches` function in the lookup file. Provided a comment in the configs file explaining the purpose and version of the exported Google Safe Browsing API endpoint. --- src/configs.ts | 3 +++ src/lookup.ts | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/configs.ts b/src/configs.ts index 4dff814..b5b8677 100644 --- a/src/configs.ts +++ b/src/configs.ts @@ -1 +1,4 @@ +/** + * The base URL of the Google Safe Browsing API. The current version is v4. + */ export const endpoint = 'https://safebrowsing.googleapis.com/v4' diff --git a/src/lookup.ts b/src/lookup.ts index 47e31a5..0479a99 100644 --- a/src/lookup.ts +++ b/src/lookup.ts @@ -28,6 +28,26 @@ export type FindThreadMatchesResponse = { /** * Finds threat matches using Google Safe Browsing API. * + * @example + * ```ts + * const result = await findThreadMatches('apiKey', { + * client: { + * clientId: 'uniqueClientId', + * clientVersion: '1.0.0', + * }, + * threatInfo: { + * threatTypes: ['MALWARE', 'SOCIAL_ENGINEERING'], + * platformTypes: ['ALL_PLATFORMS'], + * threatEntryTypes: ['URL'], + * threatEntries: [ + * { url: 'http://malware.testing.google.test/testing/malware/' }, + * ], + * }, + * }) + * + * const hasRisk = result.matches !== undefined && result.matches.length > 0 + * ``` + * * @param apiKey The API key for accessing the Google Safe Browsing API. You should follow the instruction to get the API key at https://developers.google.com/safe-browsing/v4/get-started. * @param request The request object containing the parameters for finding thread matches. *