Skip to content

Releases: LOKE/http-client

v2.0.0-rc.2

v2.0.0-rc.2 Pre-release
Pre-release

Choose a tag to compare

@THEjacob1000 THEjacob1000 released this 20 Jan 03:23
18bec0f

Changelog

Version 2.0.0-rc.2

Features

  • Now Returns Headers
    • Added the ability to receive and use the headers returned from the request

v2.0.0-rc.1

v2.0.0-rc.1 Pre-release
Pre-release

Choose a tag to compare

@THEjacob1000 THEjacob1000 released this 17 Jan 04:46
0932249

Changelog

Version 2.0.0-rc.1

This is a major update that includes breaking changes and significant improvements to the HTTP client library.

Breaking Changes

  1. Removed dependency on got library

    • The HTTP client now uses the native fetch API instead of got.
    • This change may affect how requests are made and how responses are handled.
  2. Updated prom-client to be a peer dependency

    • You now need to install prom-client separately if you want to use metrics.
  3. Removed @types/got and @types/url-template dependencies

    • These are no longer needed due to the removal of got and the update to url-template.
  4. Updated minimum Node.js version

    • The library now requires a Node.js version that supports native fetch.
  5. Changed the request method signature

    • The method now returns a Promise<Result> instead of the previous return type.
  6. Changed the options type

  • The method now takes options that are entirely different to the previous GotOptions
  • Timeout that now needs to be passed in with it's own AbortController

New Features

  1. Native fetch API support

    • This provides better compatibility with modern JavaScript environments (v22).
  2. Improved TypeScript support

    • Updated to TypeScript 5.7.2 for better type inference and stricter checks.
  3. ESLint integration

    • Replaced TSLint with ESLint for better code quality checks.

Dependency Updates

  • Upgraded url-template to version 3.1.1
  • Removed got dependency
  • Updated dev dependencies to their latest versions

How to Upgrade

  1. Update your package.json:
{
  "dependencies": {
    "@loke/http-client": "^2.0.0",
    "prom-client": "^12.0.0" // or later
  }
}
  1. If you were using got-specific features, you'll need to refactor your code to use the new fetch-based API.

  2. Update your imports if you were directly using any of the removed dependencies.

  3. Review and update your usage of the request method to handle the new Result type.

  4. Run your tests and check for any breaking changes in your application.

Code Migration Examples

Before:

import { HTTPClient } from '@loke/http-client';

const client = new HTTPClient({ baseUrl: 'https://api.example.com' });
const response = await client.request('GET', '/users/{id}', { id: 123 });
console.log(response.body);

After:

import { HTTPClient } from '@loke/http-client';

const client = new HTTPClient({ baseUrl: 'https://api.example.com' });
const result = await client.request('GET', '/users/{id}', { id: 123 });
console.log(result.body);

Note: The result object now has a different structure. Make sure to check the statusCode and handle the body appropriately.

If you encounter any issues during the upgrade process, please refer to the detailed documentation or open an issue on the project's repository.