influxdata / influxdb-client-js

InfluxDB 2.0 JavaScript client
https://influxdata.github.io/influxdb-client-js/
MIT License
327 stars 70 forks source link

feat: add headers to http error responses #1019

Closed twosdai closed 3 months ago

twosdai commented 3 months ago

Fixes https://github.com/influxdata/influxdb-client-js/issues/1018

Proposed Changes

Adds headers to the HTTP error response.

Checklist

twosdai commented 3 months ago

I am not super familiar with this repo, and this is my first contribution here. Please take a bit more time and review the code. Happy to make any changes you callout.

The basic idea of this change is to include a headers object in the HttpError thrown by influx. There are multiple different "types" of header formats, I chose to boil them down to the internal format which is basically just a simple Record<string, string> This means that for the browser client we need to go over each header value and map it into a object and then pass it in. Since the default Headers from the response object will cause typescript to error out at compile time.

codecov-commenter commented 3 months ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (e65b8fb) to head (70a8805).

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1019 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 35 35 Lines 1448 1449 +1 Branches 344 344 ========================================= + Hits 1448 1449 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

twosdai commented 3 months ago

@bednar Thanks for the comments, I've implemented the change here: https://github.com/influxdata/influxdb-client-js/pull/1019/commits/c3fb1fa341485af87aff9439277eb6bc91fa456f

Let me know if you need / want anything else.

twosdai commented 3 months ago

@bednar See the commit here for the changelog update: https://github.com/influxdata/influxdb-client-js/pull/1019/commits/643e6f433d2237d2ec9fe278db1708f0cef7a84f

Let me know if you need anything else! Thanks for the quick review :)