Skip to content

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Feat: Add browserless App #1087

wants to merge 1 commit into from

Conversation

jovenan
Copy link
Contributor

@jovenan jovenan commented Apr 5, 2025

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

Record a quick screencast describing your changes to help the team understand and review your contribution. This will greatly assist in the review process.

Demonstration Link

Provide a link to a branch or environment where this pull request can be tested and seen in action.

Copy link
Contributor

github-actions bot commented Apr 5, 2025

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 0.67.1 update
  • 🎉 for Minor 0.68.0 update
  • 🚀 for Major 1.0.0 update

@@ -0,0 +1,973 @@
const BASE_URL = "https://chrome.browserless.io";
Copy link
Contributor

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> {
Copy link
Contributor

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.

Comment on lines +631 to +638
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
}
Copy link
Contributor

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 }> {
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants