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

Fastify returns FST_ERR_CTP_INVALID_CONTENT_LENGTH

I'm struggling with pretty weird error I'm getting from the Fastify on Node JS. The server has a post service which is supposed to handle requests of gzipped JSONs body. When I try to test it using curl or any other http client, I'm getting Request…
Denis Voloshin
  • 768
  • 10
  • 32
0
votes
1 answer

Parallel save error in mongoose post init hook. Can't save() the same doc multiple times in parallel

So here's a problem which i am facing when i am using the post init hook whenever the date changes i update some values in the db. but when i am trying to make a get call the parallel save error comes up, but the values in database get updated and…
0
votes
0 answers

Using promise for array with mapping

Seems map from json does take time, and I want to wait for it using promise. formatDataOutput: function (jsonData) { return new Promise(function (resolve, reject) { let a = JSON.parse(jsonData) let b = data.b.map(p => ({ store:…
Anonymous
  • 11
  • 1
0
votes
1 answer

What is the correct implementation for multiple simultaneous servers when running NestJS with @nestjs/platform-fastify?

I am trying to run two simultaneous servers on a NestJS app running with the @nestjs/platform-fastify integration (specifically I am trying to run one HTTP and one HTTPS server of the same app). NestJS documentation includes multiple-servers for…
jengel
  • 323
  • 4
  • 10
0
votes
2 answers

Find, if not exists, insert, vulenrability

Performing >10 requests, at least, at the same time, this code inserting 4 same records, but must insert only 1. User could start only 1 active game. (in active game field finished = false) console.log('performing request'); const activeGame = await…
0
votes
0 answers

NodeJS in GCloud Error: not find openssl path

I'm working with NodeJS and Fastify in Google Cloud App Engine I connected to the console of instances with ssh I executed "which openssl" and the result was "/usr/bin/openssl" so I configured my server.js in this way const pem =…
0
votes
1 answer

Cannot read .sign of undefined error being thrown with Fastify

I am creating my server the following way: const createServer = options => { const { logSeverity } = options; const server = Fastify({ ignoreTrailingSlash: true }); server.listen(5000, err => { if (err) { …
Mike K
  • 7,621
  • 14
  • 60
  • 120
0
votes
0 answers

Nodejs killed Sharp process by timeout 5 sec

I use sharp on Hook to resize images on the fly in fastify. fastify.addHook('onSend', async (request, reply, payload) => { const newPayload = await sharp(payload.filename).resize(200, 100).toFormat('jpg').toBuffer(); return…
Alexufo
  • 1,723
  • 1
  • 15
  • 30
0
votes
1 answer

Why sequelize insert twice?

I try to insert a data into databased, but when de endpoint was called, the data was inserted twice. I try to use async await, call model outside the function, use promise, and the problem not resolved. Insert: exports.create = (req, res) => { let…
0
votes
2 answers

Fastify + Boom not returning anything other than 500

Here is a part of my code I am trying const boom = require('boom') exports.checkOtp = async (req, reply) => { try { return boom.badRequest('no active otp') } catch (err) { throw boom.boomify(err) } } I am getting { …
niksmac
  • 2,667
  • 3
  • 34
  • 50
0
votes
1 answer

Typescript fastify http2 types not being passed

I have followed the docs for a simple typescript setup import fastify from 'fastify' import { Server, IncomingMessage, ServerResponse } from 'http' import http2 from 'http2' import fs from 'fs' import path from 'path' function createRoutes(server:…
david_adler
  • 9,690
  • 6
  • 57
  • 97
0
votes
2 answers

How do i call third party API data via fastify?

I had a small node server and I use the framework fastify. In one of my routes, I want to get the data from a third party API. I tried the following snippet: fastify.route({ method: 'GET', url: 'https://demo.api.com/api/v2/project/', …
user5296504
0
votes
1 answer

Fastify JSON Schema Default Value of `null`

I'm using Fastify v2 with the built in AJV JSON Schema validator. I'm pulling some data from another service and sometimes fields are present, sometimes not. That's fine, but if the field is undefined, I'd like to default it to null instead of…
Paul Milham
  • 526
  • 5
  • 13
0
votes
1 answer

Convert callbacks to observable rxjs

I wanna create an Interceptor of nestjs and on this level and want to do uploading file. I can't find a solution, how to resolve this code by Observable (https://github.com/fastify/fastify-multipart) I'm using fromPromise but with this tool, I've…
rysalka
  • 51
  • 1
  • 7
0
votes
1 answer

Authentication with Fastify-gql plugin

Any Example on how to leverage fastify-jwt plugin with fastify-gql for authentication?. I want to protect '/graphql' route but not '/' and '/health' routes. Any help is appreciated?
thotam
  • 941
  • 2
  • 16
  • 31