-
Notifications
You must be signed in to change notification settings - Fork 98
Feat: Add browserless App #1087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Tagging OptionsShould a new tag be published when this PR is merged?
|
@@ -0,0 +1,973 @@ | |||
const BASE_URL = "https://chrome.browserless.io"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the BaaS V1. Shouldn't we be using BaaS V2?
/** | ||
* @description Represents the response structure from the Browserless API. | ||
*/ | ||
interface BrowserlessApiResponse<T = unknown> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a type.ts only for types, so the client can focus on the logic itself.
let errorMessage = | ||
`Browserless API failed: ${response.status} ${response.statusText}`; | ||
try { | ||
const errorData = await response.json(); | ||
errorMessage += `. Details: ${JSON.stringify(errorData)}`; | ||
} catch (_) { | ||
// Ignore JSON parsing error | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract to function and reuse.
/** | ||
* @description Download files using the browser | ||
*/ | ||
async download(params: DownloadParams): Promise<{ base64Image: string }> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems that all functions have the same "body":
given an URL, extract token, fetch, test for error, process response.
Maybe you should create a base function that receives the URL, and a lambda to process response, and wrap all the functions from this client.
What is this Contribution About?
Feat: Add browserless App
Please provide a brief description of the changes or enhancements you are proposing in this pull request.
Issue Link
Please link to the relevant issue that this pull request addresses:
Loom Video
Demonstration Link