Skip to content

refactor: replace axios and form-data with Node built-in fetch and FormData#124

Open
shazron wants to merge 3 commits intomasterfrom
remove-axios-form-data
Open

refactor: replace axios and form-data with Node built-in fetch and FormData#124
shazron wants to merge 3 commits intomasterfrom
remove-axios-form-data

Conversation

@shazron
Copy link
Copy Markdown
Member

@shazron shazron commented Apr 1, 2026

Summary

  • Removes axios and form-data production dependencies
  • Replaces axios.request() with the Node built-in fetch (global in Node >=20)
  • Replaces the form-data npm FormData with the Node built-in FormData (global in Node >=20)
  • Internally buffers the certificate stream into a Blob before appending to FormData, since the native API only accepts Blob/File/string (not Node.js Readable streams) — preserving the existing public API
  • Removes the manual Content-Type: multipart/form-data header so the runtime sets it automatically with the correct multipart boundary
  • Updates tests to mock global.fetch via jest.spyOn instead of jest.mock('axios')

Test plan

  • All existing unit tests pass (npm test)
  • 100% statement/branch/function/line coverage maintained
  • No lint errors
  • manual npm run e2e (verified: Transporter API has some regressions but adapted to it)

🤖 Generated with Claude Code

…rmData

Node >=20 provides fetch and FormData as globals, making the axios and
form-data dependencies unnecessary. Streams are buffered internally before
appending to FormData since the native API only accepts Blob/File/string.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ateCredentialDirect

- Pass 'certificate' as the filename when appending a Blob to FormData,
  avoiding the default "blob" filename that browsers/runtimes report
- Check res.ok after fetch and throw a shaped error on non-2xx responses
  so callers retain the same error-path behaviour as the previous axios implementation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shazron shazron requested a review from dthampy April 3, 2026 15:02
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.

4 participants