feat!: Client#post() always returns array of responses #23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes several changes to improve the handling of responses and type definitions in the
src/bin.js
andsrc/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 ofClient#post()
so that it always returns an array of responses, similar toPromise.allSettled()
. This also allows you to register multiple different versions of the same strategy to post to.Improvements to response handling:
src/client.js
: AddedSuccessResponse
andFailureResponse
classes to represent successful and failed responses, respectively.src/client.js
: Updated thepost
method in theClient
class to return an array ofSuccessResponse
orFailureResponse
objects instead of a mixed object.src/bin.js
: Updated the handling of responses to use the newisSuccessResponse
helper function and log results accordingly.Improvements to type definitions:
src/bin.js
: Added type definitions and updated theoptions
object to use a constant type for boolean values.src/bin.js
: Added type annotations for thestrategies
array.Updates to tests:
tests/client.test.js
: Updated tests to check forSuccessResponse
andFailureResponse
objects instead of mixed objects. [1] [2] [3]