Skip to content

@major-tanya/itty-compression v0.2.0

Compare
Choose a tag to compare
@MajorTanya MajorTanya released this 09 Apr 06:21
· 5 commits to main since this release
v0.2.0
767ccf2

This is a breaking change, see “How to migrate”

This release is a substantial rewrite of the inner mechanics of itty-compression.

Changes:

  • (BREAKING) Swapped order of arguments (now Response comes first, Request comes second)
  • (BREAKING) Middlewares can now only accept Response objects for their input and not arbitrary content (make sure you have a formatter/handler middleware set before any of the compression ones)
  • Fixed Vary header not being added/updated when using the single algorithm middlewares
  • Make use of generics in internal systems

How to migrate

  • Swap the argument order of Request and Response like this:
// example export, your exact setup might look different
export default {
  fetch: (request, ...args) => router
    .handle(...args)
    .then(json)
-   .then((response) => negotiatedCompression(request, response))
+   .then((response) => negotiatedCompression(response, request))
    .catch(error),
};

This swapping was necessary to allow for very concise syntax with itty-router's more batteries-included v5 routers. Also, check out whether AutoRouter or the medium Router may be useful to you, they are more concise than the v4 router (which still exists as IttyRouter now).

Although this is a breaking release, it is only a minor version increase, as itty-compression is not considered stable at this time. There are no further breaking changes like this expected in the future, but that is not a guarantee they won't happen.

Full Changelog: v0.1.6...v0.2.0