Skip to content

Version 5.0.0

Compare
Choose a tag to compare
@Avaq Avaq released this 16 Apr 11:16
· 11 commits to master since this release
7375125

Version 5.0.0

This version is a partial rework of the library to allow users to use more of the features normally available in Express. See #31 for the changes in code.

✨ New Features

Most of Express' interface for modifiying the Response head is now available

There's also a new withoutHeader function to remove specific headers from a Response.

⚠️ Breaking Changes

The internal structure of the Response type changed

If you were manually interpreting values of type Response, for example by using the .cata method, then this change will affect you. For standard usage of this library, this change shouldn't affect you.

The middleware and dispatch functions now expect a curried input function

Instead of (req, locals) => /* Future Response */, middleware now looks like locals => req => /* Future Response */

-app.use (middleware ((req, locals) => (
+app.use (middleware (locals => req => (
   resolve (Empty)
))

The Stream constructor takes different arguments

  • It no longer takes the response code and the mime type as arguments.
  • It no longer takes a Readable instance directly, but rather a Future Error Readable. This allows the value created via the Stream constructor to be passed around safely (instances of Readable throw an error after a short timeout if no listerners are attached).
- Stream (202) ('image/jpeg') (fs.createReadStream ('./cat.jpeg'))
+ withStatus (202) (withType ('image/jpeg') (Stream (Future.ecanse (fs.createReadStream) ('./cat.jpeg'))))

The Json constructor no longer takes the response code

- Json (202) ({hello: world})
+ withStatus (202) (Json ({hello: world}))

The Render constructor no longer takes the response code

- Render (202) ('template') ({hello: world})
+ withStatus (202) (Render ('template') ({hello: world}))

The Redirect constructor no longer takes the response code

- Redirect (303) ('example.com')
+ withStatus (303) (Redirect ('example.com'))