Skip to content

Releases: gustavoguichard/make-service

v3.1.0

02 Aug 15:26
f7b4aff
Compare
Choose a tag to compare

What's Changed

Main change: the trace function now gets a third parameter which is a clone of the TypedResponse so you can debug not only the requests but also the response ;)

PRs:

  • docs: add iamandrewluca as a contributor for code, promotion, and 3 more by @allcontributors in #49
  • fix(makeFetcher): include requestTransformer headers by @iamandrewluca in #48
  • Add third parameter with response to trace and allow it to be asynchronous by @diogob in #53
  • Updating packages, vite, and lint config by @gustavoguichard in #54

New Contributors

Full Changelog: v3.0.0...v3.1.0

v3.0.0 - small changes in a major version

30 Jan 14:53
00c095c
Compare
Choose a tag to compare

Why is it a major change?

This version are introducing little changes but it has 1 breaking change.
In the past we adopted a convention to add "content-type": "application/json" headers as default to makeService, but as lots of early conventions it has proven to be a bad decision as depending on the format of the body the content-type needs to be different and we are now using make-service to deal with every type of request instead of just JSON APIs.

We are dropping that default so you might want to add that if you rely on that behavior.
If that's your case, you'll need to change your code like so:

# From
const service = makeService(BASE_URL)
# To
const service = makeService(BASE_URL, { headers: { "content-type": "application/json" } })

An important bugfix:

We had our first solid contribution from @iamandrewluca . To change the behavior of the response so it gets typed on the fly we are using JS Proxys. It works like a charm but for the methods we are not hijacking (.json() and .text()) we are now using Reflect so we don't mess with the Response's prototype.
This bugfix should fix an issue where response.blob() or response.arrayBuffer() would never resolve.

This is a "small major" release, let us know if you had any trouble upgrading. We appreciate any sort of collaboration ;)

What's Changed

  • docs: add iamandrewluca as a contributor for doc by @allcontributors in #43
  • fix(typedResponse): bind remaining Proxy methods to Response by @iamandrewluca in #47
  • BREAKING CHANGE: Drop the behavior of adding a default content-type: application/json by @gustavoguichard in #45

Full Changelog: v2.1.2...v3.0.0

v2.1.2

08 Nov 12:09
5794436
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v2.1.1...v2.1.2

v2.1.1

17 Oct 20:27
af70841
Compare
Choose a tag to compare

What's Changed

  • chore: Add contributors and other shields to README by @gustavoguichard in #37
  • fix: add more strict function definitions too addQueryToURL by @garusis in #35

New Contributors

Full Changelog: v2.1.0...v2.1.1

v2.1.0

20 Sep 13:48
6086b1d
Compare
Choose a tag to compare

🆕 What's Changed

  • fix: Add 'Date', 'undefined', and 'null' as possible JSON values to improve DX by @gustavoguichard in #34

🐞 Bug fixes

  • Fixes a bug where addQueryToURL would not work with URLs with empty searchParams by @gustavoguichard in #32

Other PRs

Full Changelog: v2.0.0...v2.1.0

v2.0.0

08 Aug 18:19
e11f6a6
Compare
Choose a tag to compare

What's Changed

BREAKING Changes:

Dropped string transformations

String transformations such as kebabToCamel and etc were removed from this library. We recommend replacing it by string-ts which is much more powerful and fully featured.

// BEFORE v2
import { makeService, kebabToCamel } from 'make-service'

const service = makeService("https://example.com/api")
const response = await service.get("/users")
const users = await response.json(
  z
    .array(z.object({ "first-name": z.string(), contact: z.object({ "home-address": z.string() }) }))
    .transform(kebabToCamel)
)

// AFTER v2
import { makeService } from 'make-service'
import { deepCamelKeys } from 'string-ts'

const service = makeService("https://example.com/api")
const response = await service.get("/users")
const users = await response.json(
  z
    .array(z.object({ "first-name": z.string(), contact: z.object({ "home-address": z.string() }) }))
    .transform(deepCamelKeys)
)

With string-ts you don't need to specify the input casing of the string, you only need to specify the target casing. 🔥

Changes to the second argument of makeService

Now the second argument to makeService and makeFetcher functions is baseOptions which is an object with headers, requestTransformer, and responseTransformer. You can use the new transformers to pre-process your Request before sending it or post-process your Response just after fetching.
This allows further customization of this library such as creating adapters for APIs that will transform the payloads back and forth.
Turning the second parameter into an object will also allow future new APIs to come to this library.

How to migrate:

You just need to send your former baseHeaders in the baseOptions.headers now as so:

// Versions < 2.0.0
const service = makeService('https://google.com', new Headers({ authorization: "Bearer 123" }))

// From versions >= 2.0.0
const service = makeService('https://google.com', {
  headers: new Headers({ authorization: "Bearer 123" }),
})

Acknowledgements

I appreciate all the effort by @danielweinmann, @diogob , and the team at SeasonedSoftware that made it to this release.

Full Changelog: v1.1.0...v2.0.0

v2.0.0-next.0

07 Jun 12:32
a6da4a7
Compare
Choose a tag to compare
v2.0.0-next.0 Pre-release
Pre-release

What's Changed

BREAKING Changes:

Now the second argument to makeService and makeFetcher functions is baseOptions which is an object with headers, requestTransformer, and responseTransformer. You can use the new transformers to pre-process your Request before sending it or post-process your Response just after fetching.
This allows further customization of this library such as creating adapters for APIs that will transform the payloads back and forth.
Turning the second parameter into an object will also allow future new APIs to come to this library.

How to migrate:

You just need to send your former baseHeaders in the baseOptions.headers now as so:

// Versions < 2.0.0
const service = makeService('https://google.com', new Headers({ authorization: "Bearer 123" }))

// From versions >= 2.0.0
const service = makeService('https://google.com', {
  headers: new Headers({ authorization: "Bearer 123" }),
})

Acknowledgements

I appreciate all the effort by @danielweinmann, @diogob , and the team at SeasonedSoftware that made it to this release.

Full Changelog: v1.1.0...v2.0.0-next.0

v1.1.0

10 May 03:38
e5a7bea
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.0.0...v1.1.0

v1.0.0

09 May 13:49
4a4baeb
Compare
Choose a tag to compare

What's Changed

Updated README

You can see all the new features an APIs in the updated and reorganized README.

New Contributors

Full Changelog: v0.2.0...v1.0.0

v1.0.0-next.2

09 May 13:45
95ff536
Compare
Choose a tag to compare
v1.0.0-next.2 Pre-release
Pre-release

What's Changed

Full Changelog: v1.0.0-next.0...v1.0.0-next.2