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
5
votes
1 answer

End-to-end testing NestJS with Fastify: "@nestjs/platform-express" package is missing" error

I have fresh NestJS application using Fastify. When trying to npm run test:e2e I got the following error: [Nest] 14894 - 11/19/2021, 10:29:10 PM [ExceptionHandler] The "@nestjs/platform-express" package is missing. Please, make sure to install…
Daniel Kucal
  • 8,684
  • 6
  • 39
  • 64
5
votes
2 answers

Fastify with Heroku

I am having a simple Fastify server hosted with Heroku. But, it seems not working ! But, it seemed all right during the development! The error I get is: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch.…
Ajit Kumar
  • 367
  • 1
  • 10
  • 35
5
votes
3 answers

NestJS Fastify Authentication

So I replaced ExpressJS with Fastify, but my problem is Nest-Passport doesn't support fastify, do we have an alternative for Nest-Passport? or any solutions on how to secure RestAPI in nestJS using a token?
Dan
  • 69
  • 2
  • 8
5
votes
5 answers

NestJS Middleware Not Executed

The NestJS class or functional middleware doesn't run when connected from a Module. It is also not working for a single path, controller or for every path. Connecting functional middleware from main.ts works fine. //main.ts import { ValidationPipe…
Roman Sivtsov
  • 181
  • 1
  • 8
5
votes
2 answers

Nestjs - file upload with fastify multipart

I am trying to upload multiple files with nestjs using the fastify adapter. I can do so following the tutorial in this link -article on upload Now this does the job of file upload using fastify-multipart, but I couldnt make use of the request…
vijayakumarpsg587
  • 1,079
  • 3
  • 22
  • 39
5
votes
2 answers

How to set response header in nestjs with fastify

I'm trying to set a custom reponse header in a nest js controller and using fastify. Currently I'm trying to do: @Post() async methodName(@Res res){ res.set('key', 'value'); }; But I get the error: res.set is not a function Can someone help me?
Lex den Otter
  • 133
  • 1
  • 7
5
votes
1 answer

fastify, jest: running processes after calling .close() on fastify instance

I have the following function for opening a database connection and running my fastify server instance (server.js) import fastify from "fastify"; import fastifyCors from "fastify-cors"; import { MongoClient } from "mongodb"; import characterRoute…
Miha Šušteršič
  • 9,742
  • 25
  • 92
  • 163
5
votes
1 answer

Fastify schema validation multipart/form-data (body should be object)

Multipart form data file uplaod time comming error body should be object, and i am using ajv plugin also, still i am using same issue. below is my reference code. app.js const fastify = require('fastify')({ logger: true }); const Ajv =…
Ravi Teja
  • 649
  • 7
  • 17
5
votes
3 answers

Is there anyway to get types interfaces for request, response in Nest.js with Fastify

I am learing Nest.js and on the beging of documentation I read that I can use it not only with express but also with fastify so I setuped up my first project with fastify then I started to read about controllers and I found a problem. For example if…
Krzysztof Kaczyński
  • 4,412
  • 6
  • 28
  • 51
5
votes
2 answers

How to Ignore a specific route logging using Fastify in NestJs?

I want to ignore or change the logLevel of a route in my NestJs application using Fastify. This is how I do it normally in Fastify application. Here I am changing the /health route logLevel to error so that it will only log when there is an error…
Anwaar Malik
  • 121
  • 3
  • 7
5
votes
2 answers

Wait for one plugin to finish registering, before proceeding to register the next one

How can I wait for one plugin to finish registering, before proceeding to register the next one? I wish to initialize the connection to the database using credentials that are retrieved from a .env file using the plugin fastify-env. Fastify proceeds…
Publicus
  • 1,550
  • 7
  • 18
  • 33
5
votes
2 answers

Logging Fastify response body

How can I log the response body in Fastify? The body doesn't seem to be exposed as part of the response object: const fastify = require('fastify')({ logger: { serializers: { res: function (res) { // No body in req afaik …
cyberwombat
  • 38,105
  • 35
  • 175
  • 251
4
votes
2 answers

Why is TypeORM DataSource initialization seemingly setting my host to localhost instead of my public IP?

I'm not sure if this is possible, but I don't see why it wouldn't be, so I'm a little stumped. I've been trying to connect to a remote SQL DB hosted on google cloud through a locally running instance of my Node application, but it keeps failing with…
Musilix
  • 330
  • 2
  • 14
4
votes
1 answer

How can I use fastify request logger in other classes without having to pass it as a parameter?

I'm new in nodejs, I'm using fastify and I want to be able to use the req.logger in all the classes functions of the flow, this because I have a the request-id on req.logger, the first solution that came to my mind is to pass as a parameter the…
4
votes
1 answer

SSE connection not established

I have implemented Server-Sent events with fastify. The client code: const url = `${server}/sse/events`; const connection = new EventSource(url); connection.onopen = () => { console.log('The connection has been…
elli
  • 497
  • 1
  • 3
  • 10
1 2
3
44 45