Skip to content

enables returning Response and ReadableStream as a result value in fastify routes

Notifications You must be signed in to change notification settings

erfanium/fastify-web-response

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastify-web-response

enables returning Response and ReadableStream as a result value in fastify routes.
so this code will be work:

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

app.route({
  method: "GET",
  url: "/",
  async handler() {
    const response = await fetch("https://example-api.com");
    return response.body;
  }
})

Installation

npm i fastify-web-response

Experimental

fetch api is experimental. I'll release the v1.0.0 of this module when it's stable

About

enables returning Response and ReadableStream as a result value in fastify routes

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published