Skip to content
This repository has been archived by the owner on Dec 24, 2021. It is now read-only.

Releases: noel-archive/orchid

3.1.0: Bug-fix release

16 May 00:56
Compare
Choose a tag to compare

Fixes

  • ff18c80 How URIs are constructed when creating a request
  • a321ee1 Response.json typings

3.0.2

25 Apr 19:32
Compare
Choose a tag to compare

Fixes

  • Typings
  • URL fixes

3.0.0

19 Apr 05:25
Compare
Choose a tag to compare

Additions

  • Use undici for better performance
  • Simpler middleware API
  • Added path param support for requesting

Removed

  • All deprecated getters and methods from v2

2.2.3 | Patch Build

16 Mar 20:47
Compare
Choose a tag to compare

Fixes

  • (typings) Fix serializer typings (#184)
  • (typings) Fix Response.json<T>() typings

2.1.0

15 Feb 21:24
Compare
Choose a tag to compare

Fixes

  • Typings
  • Code cleanup

2.0.0 | Better Middleware API, Custom Serialization

15 Feb 04:25
Compare
Choose a tag to compare

Additions

  • Better Middleware API
  • Serialization API
  • Added Response.body() to use the Serialization API

Fixes

  • multipart/form-data Support

Deprecated stuff

  • Response.successful -> Response.success
  • Response.isEmpty -> Response.empty

Serialization

Orchid allows you to serialize your own data without doing it yourself every time you make a request.

An example on building a XML serializer would look like this:

const { Serializer } = require('@augu/orchid');

module.exports = class XMLSerializer extends Serializer {
  constructor() {
    super(/application\/xhtml[+]xml/gi);
  }

  serialize(data) {
    const str = data.toString();
    return someXMLParser(str);
  }
}

Then we inject it into our http client or adding it with orchid#method

// HttpClient
const client = new HttpClient({
  serializers: [new XMLSerializer()]
});

// Method function
orchid.get({
  serializers: [new XMLSerializer()]
});

Better Middleware API

Orchid now has a new middleware API that is executed on different types. The old API would look like this:

const { CycleType } = require('@augu/orchid');

module.exports = () => ({
  cycleType: CycleType.Execute,
  name: 'my:mid',
  intertwine() {
    // Now we do stuff here, we don't add the middleware since it does itself
  }
});

This is not an ideal API to use because it didn't support more than 1 type and naming conventions didn't make sense. The new API would look like this:

const { MiddlewareType } = require('@augu/orchid');

module.exports = {
  type: [MiddlewareType.None],
  name: 'name',

  run(client, type) {
    // this => this middleware
    // client => The HttpClient used
    // type => The middleware type
  }
};