Skip to content
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

feat!: Client#post() always returns array of responses #23

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

Conversation

nzakas
Copy link
Contributor

@nzakas nzakas commented Dec 16, 2024

This pull request includes several changes to improve the handling of responses and type definitions in the src/bin.js and src/client.js files, as well as updates to the corresponding tests.

The Client#post() method previously threw an error when an API request failed, meaning you wouldn't get any info about requests that succeeded. This PR changes the behavior of Client#post() so that it always returns an array of responses, similar to Promise.allSettled(). This also allows you to register multiple different versions of the same strategy to post to.

Improvements to response handling:

  • src/client.js: Added SuccessResponse and FailureResponse classes to represent successful and failed responses, respectively.
  • src/client.js: Updated the post method in the Client class to return an array of SuccessResponse or FailureResponse objects instead of a mixed object.
  • src/bin.js: Updated the handling of responses to use the new isSuccessResponse helper function and log results accordingly.

Improvements to type definitions:

  • src/bin.js: Added type definitions and updated the options object to use a constant type for boolean values.
  • src/bin.js: Added type annotations for the strategies array.

Updates to tests:

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.

1 participant