Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/erfanium/fastify-web-response
enables returning Response and ReadableStream as a result value in fastify routes
https://github.com/erfanium/fastify-web-response
fastify fastify-plugin fetch-api node
Last synced: 11 days ago
JSON representation
enables returning Response and ReadableStream as a result value in fastify routes
- Host: GitHub
- URL: https://github.com/erfanium/fastify-web-response
- Owner: erfanium
- Created: 2023-01-13T06:12:13.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-04T18:22:33.000Z (12 months ago)
- Last Synced: 2024-10-04T13:44:07.444Z (about 2 months ago)
- Topics: fastify, fastify-plugin, fetch-api, node
- Language: TypeScript
- Homepage:
- Size: 71.3 KB
- Stars: 16
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# fastify-web-response
enables returning `Response` and `ReadableStream` as a result value in fastify routes.
so this code will be work:```js
import fastify from "fastify"
import fastifyWebResponse from "fastify-web-response"const app = fastify();
app.register(fastifyWebResponse)
app.route({
method: "GET",
url: "/",
handler() {
return fetch("https://example-api.com");
}
})app.listen({
port: 3000
})
```you can also return ReadableStream
```js
app.route({
method: "GET",
url: "/",
async handler() {
const response = await fetch("https://example-api.com");
return response.body;
}
})
```## Installation
```sh
npm i fastify-web-response
```## Experimental
`fetch` api is experimental. I'll release the v1.0.0 of this module when it's stable