Skip to content

Commit

Permalink
fix(docs): refactor and improve documentation in lookup.ts
Browse files Browse the repository at this point in the history
Made improvements to the code organization and comments in lookup.ts for better clarity and readability. Rearranged blocks of code and revised descriptions related to 'FindThreadMatchesRequest' and 'FindThreadMatchesResponse' objects. This is meant to give a clearer understanding of these objects' structure and their usage in the Google Safe Browsing
  • Loading branch information
hckhanh committed Mar 1, 2024
1 parent b36db72 commit 91c4eae
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ A JavaScript client for [Google Safe Browsing](https://safebrowsing.google.com)
## Features

- [Zero dependency](https://jsr.io/@hckhanh/google-safe-browsing/dependencies)
- Edge runtime built-in support
- Built-in support for Edge runtime
- Typesafe with TypeScript
- Support all Google Safe Browsing API v4 endpoints
- Fully well-documented
- Supports all Google Safe Browsing API v4 endpoints
- Fully documented

## Release Notes

Expand Down
46 changes: 26 additions & 20 deletions src/lookup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
import type { ClientInfo, ThreatInfo, ThreatMatch } from './types.ts'
import { endpoint } from './configs.ts'

/**
* @module
* The Lookup API lets your client applications send requests to the Safe Browsing
* servers to check if URLs are included on any of the Safe Browsing lists.
* If a URL is found on one or more lists, the matching information is returned.
*
* @example
* ```ts
* import { findThreadMatches } from '@hckhanh/google-safe-browsing'
*
* 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/' },
* ],
* },
* })
*/

/**
* The request object containing the parameters for finding thread matches.
*/
Expand Down Expand Up @@ -28,26 +54,6 @@ 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.
*
Expand Down

0 comments on commit 91c4eae

Please sign in to comment.