Skip to content

Expanded HTTP method support (PATCH/OPTIONS/CONNECT/TRACE), enhanced request options, and file upload fix

Choose a tag to compare

released this 10 Aug 16:24
· 50 commits to working since this release

This release focuses on broadening HTTP method coverage and refining the request options model. It adds first-class support for PATCH, OPTIONS, CONNECT, and TRACE, introduces query parameter handling and finer-grained content negotiation controls, and fixes a cross-environment file upload issue. Documentation and tests have been updated to reflect and validate these changes.

New Features

  • Added additional HTTP methods
    • New API factories and simple wrappers for: PATCH, OPTIONS, CONNECT, TRACE
    • New TypeScript option types exported: PatchMethodOptions, OptionsMethodOptions, ConnectMethodOptions, TraceMethodOptions
    • All methods integrate with the shared HTTP pipeline and logging
  • Expanded request options
    • params: Pass query string parameters as an object (supports string | number | boolean | Date)
    • isJsonBody: Control JSON serialization of the request body independently from response parsing
    • contentType and accept: Explicitly set Content-Type and Accept headers
    • skipContentType: Allow sending requests without an automatic Content-Type header
  • Public exports
    • index now exports options, connect, trace, patch alongside existing get, post, put, deleteMethod, postFileMethod, uploadAsyncMethod
    • Type exports updated to include the new method option types

Bug Fixes

  • File uploads
    • Fixed FormData payload creation by constructing Blob from new Uint8Array(file.buffer) to ensure correct binary uploads across Node (undici) and browsers

Breaking Changes

  • RequestOptions removal of timeout
    • The timeout field has been removed from RequestOptions and the documentation. If you previously relied on this field, migrate to a different timeout strategy (for example, using AbortController/Signal with fetch or your own wrapper) according to your environment.
  • Request options behavior clarified
    • isJson remains for response parsing; isJsonBody is introduced to control request body serialization. Review custom requests that set isJson to ensure the intended behavior for request vs. response is preserved.

Improvements

  • Query parameters support
    • generateQueryParameters integration enables consistent encoding of params for all HTTP methods
  • Documentation
    • GETTING_STARTED.md and API docs updated to list new methods (PATCH, OPTIONS, CONNECT, TRACE)
    • RequestOptions section updated to include params, contentType, accept, isJsonBody, skipContentType and remove timeout
    • Example updated to demonstrate query parameters usage
  • Index and API surfaces
    • Central index re-exports new methods and associated types to streamline imports for users

Testing Improvements

  • New and updated tests
    • Added dedicated tests for optionsMethod, connectMethod, traceMethod, patchMethod
    • Expanded example tests covering advanced configuration, authentication flows, error handling, file uploads, and API factories/exports
    • Added an index export test to verify public surface stability
  • Test configuration
    • Added module alias for '@fjell/http-api' to src in vitest.config.ts
    • Broadened coverage include paths to cover examples/**/*
    • Enforced coverage gates with higher thresholds (branches: 80, functions: 90, lines: 91, statements: 91) and enabled checkCoverage

Developer Experience

  • Tooling updates
    • Runtime dependency: @fjell/logging bumped to ^4.4.36
    • Dev dependencies refreshed: @eslint/js ^9.33.0, @fjell/eslint-config ^1.1.11, @types/node ^24.2.1, @typescript-eslint/* ^8.39.0, eslint ^9.33.0, typescript ^5.9.2, undici ^7.13.0

Usage Notes and Examples

  • Using query parameters

    import { get } from '@fjell/http-api';
    
    const data = await get('/search', {
      params: { q: 'fjell', page: 1 }
    });
  • Using new HTTP methods

    import { patch, options, connect, trace } from '@fjell/http-api';
    
    // PATCH with JSON body
    await patch('/items/123', { name: 'Updated' }, { isJsonBody: true });
    
    // OPTIONS request
    const capabilities = await options('/items');
    
    // CONNECT request (proxy/tunnel scenarios)
    await connect('/proxy');
    
    // TRACE request
    await trace('/echo');
  • Controlling content negotiation

    import { post } from '@fjell/http-api';
    
    await post('/submit', { payload: 'raw' }, {
      contentType: 'application/json',
      accept: 'application/json',
      isJsonBody: true
    });
    
    // Send without Content-Type header (e.g., for FormData)
    await post('/upload', someFormData, { skipContentType: true, isJsonBody: false });

Migration Guidance

  • If you used the timeout option, remove it and adopt a timeout mechanism compatible with your runtime (e.g., AbortController with fetch). Review custom wrappers to ensure they do not pass timeout to RequestOptions.
  • If you set isJson to control request encoding, update your calls to set isJsonBody for body serialization and keep isJson for response parsing.

Notes

  • Package version bumped to 4.4.29. API surfaces and docs have been aligned with the new HTTP methods and options.