Questions tagged [fastify]

Fast and low overhead web framework for Node.js (https://www.fastify.io)

Fastify is a web framework highly focused on providing the best developer experience with the least overhead and a powerful plugin architecture. It is inspired by Hapi and Express.

The official website of Fastify is www.fastify.io. The source can be found on GitHub.

Useful links:

Older versions

671 questions
0
votes
1 answer

How can i properly send a stream from forked child process in Node.js?

I tried something like this in the forked child process: WriterPlugin.js (child process) function sendCursor(){ try { let cursor = await getQueryCursor(reqBody, db); cursor.on('data', (data)…
Gus Evan
  • 35
  • 4
0
votes
2 answers

How to preserve request queries with fastify-http-proxy while adding an api-key query parameter in a proxy

I have a small project with a node.js + fastify server, in which I want to proxy requests to an external API using fastify-http-proxy https://github.com/fastify/fastify-http-proxy (no existing tags here). This external API wants their api-key…
B.Dwyer
  • 69
  • 12
0
votes
0 answers

Fastify async try catch does not resolve

I have simple route: fastify.post('/subscribe', { schema: subscribeSchema, handler: async (req, reply) => { try { const events = req.body.events; const allEventsProcessingData = await Promise.all(events.map(async (ev) => { …
0
votes
1 answer

Add dynamic query parameter in Swagger with Fastify

Is it possible to document dynamic query parameter using Fastify on Swagger, that allow client to pass the param value inside text field on Swagger UI using Swagger v1.0.0?, in my case is to input dynamic value of conversationId parameter. Here is…
Chanrithisak Phok
  • 1,590
  • 1
  • 19
  • 29
0
votes
0 answers

Fastify Rewrite URL

How can I use Fastify’s rewriteUrl option for all requests with a path that starts with /r/ and rewrite the url to https://example.com/example?
0
votes
0 answers

Fastify Passport on application loading getting "initialize not a function"

While trying to use the fastify-passport plugin as per documented on the npm documentation i am getting the beloe error while the application is initializing: server.register(fastifypassport.initialize()); ^ TypeError:…
vaibhav
  • 3,929
  • 8
  • 45
  • 81
0
votes
0 answers

Access object property on Fastify

I tried to fetch the value from the object on Fastify but while I was trying to do so, when I make GET request, it keeps loading and network request keep on pending. Here is how I tried, I want to access the property of the object (token) and…
Chanrithisak Phok
  • 1,590
  • 1
  • 19
  • 29
0
votes
1 answer

Specifying an optional 'object' parameter with fastify-swagger

I have a fastify API service with the below endpoint. server.route({ method: 'PUT', url: '/user/order/new', schema: { description: 'place a new order', body: { type: 'object', required: ['gross', 'name',…
Igor Shmukler
  • 1,742
  • 3
  • 15
  • 48
0
votes
1 answer

How to get notified when a Post is done with ketting

I'm actually trying the power of react-ketting with a fastify's API. From the hook useResource, I can get a submit function that will make a POST but I can't know when that submit is done and I can't get the API reply of this POST. React doesn't…
Ugo Lfe
  • 717
  • 2
  • 9
  • 27
0
votes
1 answer

FASTIFY: Is there a way for the onResponse hook to execute ONLY when the handler sends 200 and not execute in any other case?

I'm trying to increment a value when the request is successful. Yet the onResponse executes whatever the response from the handler is. Is there a way for the onResponse hook to execute ONLY when the handler sends 200 and not execute in any other…
Skillers3
  • 3
  • 3
0
votes
1 answer

Fastify - i18next in custom error handler

In my Node.js application I´m using fastify as framework together with some plugins (i18next). I´m using i18next for translation (is working properly in preHandler and handler hooks) and want to customize all errors by using my translations via…
stefano
  • 315
  • 2
  • 16
0
votes
1 answer

CORS don't work after JWT authentication added

I have a Vue frontend, an Auth0 and Fastify backend. CORS is configured as follows: fastify.register(require('fastify-cors'), { origin: 'http://localhost:8080', methods: 'GET,PUT,POST,DELETE,OPTIONS,HEAD', allowedHeaders: 'Origin,…
Dmitry
  • 727
  • 1
  • 8
  • 34
0
votes
1 answer

Registering a function that connects the app to mongoose

There's a function for connecting my app to mongoose/mongodb that I pass as argument in fastify.register(). It throws an error that says: UnhandledPromiseRejectionWarning: Error: ERR_AVVIO_PLUGIN_TIMEOUT: plugin did not start in time:…
jstarnate
  • 319
  • 3
  • 15
0
votes
1 answer

Fastify and json schema validation

I'm trying to learn fastify throught the official documentation. I'm really intrested in the validation of an incoming post request with a json schema. Following the instructions i added to my routes: fastify.addSchema({ $id:…
Mario Rossi
  • 107
  • 1
  • 4
  • 12
0
votes
1 answer

NestJS Dynamic template rendering in Fastify mode - res.render is not a function

I feel like Model-View-Controller @ docs.nestjs.com doesn't cover this use case - there is "Dynamic template rendering" section + Fastify but both combined together don't seem to work well. I've tried the following snippet: import { Get, Res } from…
BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91