0.0.7 • Published 3 years ago
wkrk-extended v0.0.7
Extended
Handy extensions that returns native Request and Response objects.
Usage
This library provides a lot of utilities, but in the end, all you get is a
native Resquest and Response objects to have maximum compatibility with all
platforms including CloudFlare Workers, Node.js, and even Service Workers!
const res = new ExtendedResponse()
res.status(500).json({ user: "giovannibenussi" })In the real world, you'll get an instance of ExtendedResponse provided by your
framework of choice, so you'll rarely call the constructor.
You can perform a redirect by calling the .redirect method:
res.redirect('http://giovannibenussitest.com', 307)As the philosophy of this library, the previous code is equivalent of calling
Response.redirect with the added benefit of having utility classes to set
headers, cookies, or whatever you want!