Questions tagged [fastify]
Fast and low overhead web framework, for Node.js.
69
questions
0
votes
1answer
29 views
NestJS fastify swagger errors while building app
I'm using fastify adapter
According to the documentation I have installed the swagger adapter for fastify
npm install --save @nestjs/swagger fastify-swagger
And when I import swagger objects
...
1
vote
1answer
25 views
How to return array() in fluent-schema?
I have an object that looks like this:
interface LotteryData {
PROP1: string;
PROP2: string;
PROP3: string;
PROP4: string;
PROP5: string;
}
interface LotterySuccess {
name: string;
...
0
votes
1answer
22 views
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 ...
1
vote
1answer
28 views
How to organize routing in fustify?
Forgive me for these heretical speeches, but I consider express to be the best library for api building from the developer experience point of view. But what stops me from using it everywhere is that ...
0
votes
0answers
63 views
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(...
0
votes
1answer
58 views
Await is not pausing execution
I can't figure out why execution continues, and await isn't pausing execution until the called function returns.
In a node.js application
Contacts.js
async function routes (fastify, options) {
...
0
votes
1answer
27 views
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).
...
0
votes
0answers
48 views
Routing Issue when using static content (Angular 8) with NestJS and Fastify
I've been searching for the last several days for a way to fix a routing issue when using static content with NestJS and Fastify. Specifically I am trying to use Angular 8 hosted by NestJS with ...
0
votes
1answer
42 views
fastify-mongodb : “mongo” is undefined when accessed
I'm attempting to use Fastify and fastify-monogdb.
Currently I have the following...
In my /src/index.js
const routes = require("./routes");
const fastify = require("fastify")({
logger: true
});
...
0
votes
2answers
62 views
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....
0
votes
0answers
61 views
File uploads with graphql-upload, apollo-server-fastify, and the NestJS code first approach
What is the correct implementation for receiving file uploads from a client on a server utilizing the following combination of packages/techniques (and their corresponding dependencies not listed):
...
0
votes
2answers
64 views
In NestJS is there any way to pass data from Guards to the controller?
So I am currently using NestJS extensively in my organization. And for authentication purposes we are using our own guards. So my question is that can anyone please guide me if there any way to pass ...
0
votes
0answers
68 views
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 ...
0
votes
2answers
79 views
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 ...
0
votes
0answers
27 views
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(...
0
votes
0answers
71 views
How to configure rate-limit with fastify-adapter in nest js
I Just started implementing API's Nest js and I am using Fastify adapter.
I need help to configure Rate limit using FastifyAdapter in Nest JS.
async function bootstrap() {
const app = await ...
2
votes
0answers
75 views
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 ...
0
votes
0answers
33 views
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, ...
0
votes
1answer
165 views
Fastify plugin fastify-autoload error plugin must be a function
I have setup the fastify framework with fastify-cli library with command fastify-cli generate. It has fastify-autoload plugin used out of the box.
But, it will throw an error when I add my own ...
0
votes
1answer
64 views
Fastify route not working with specific url
I have this router in my code
fastify.get('/:link', (req, reply) => {
req.params.url = req.host+req.url;
reply.view("template.ejs",req.params);
});
I am trying to catch URLs and handle ...
0
votes
1answer
124 views
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 ...
0
votes
1answer
71 views
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) {
...
0
votes
1answer
52 views
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'
...
0
votes
2answers
102 views
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',
...
1
vote
4answers
171 views
Fastify middleware - access to query and params?
trying to get middleware working in Fastify - I don't seem to have access to the query or params. The docs say:
Fastify supports out of the box Express/Restify/Connect middlewares, this means that ...
0
votes
1answer
182 views
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,...
1
vote
2answers
296 views
How to assign routes within a base route in fastify
I am using fastify as a web framework in my nodejs project. I want to call all my routes from a directory having a base route defined in main JS file like we do in express. I have read many blogs but ...
0
votes
1answer
56 views
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)
...
0
votes
1answer
54 views
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?
0
votes
1answer
68 views
Delay passing logger options to FastifyAdapter in Nest.js
I use Fastify instead of Express in my Nest.js application and I'd like to configure logging for Fastify. The configuration for logging (and many other things) is provided by ConfigService. However, ...
2
votes
2answers
508 views
How to parse querystring parameter from URL in Fastify server?
I am a totally new to fastify but I have a fastify server running. I want to parse query string such as:
http://fake.com/?user=123&name=ali
I want to get "user" and "name" values from the URL ...
1
vote
0answers
57 views
Create a build for Node.js (fastify) server to electron app
I am using node js 10.15.0 along with fastify server int it.
I am also using normal public folder shared in the project.
Below is the project hierarchy.
NOTE: This code when started, starts as a ...
0
votes
0answers
91 views
Using pm2 metric at fastify framework nodejs
I setup the new server with fastify as a backend.
I use pm2 as a process manager and use the pm2 metric feature. Specifically, the io meter feature. But the metric value doesn't display the correct ...
0
votes
0answers
15 views
502 Proxy Error Node.js when using rackspace
Using pkgcloud to upload file to Rackspace Cloud files causing Request Timeout and then 502 error happens makes server unusable (stopped) but not crash.
My Code :
function processImage(req, reply) {...
0
votes
1answer
75 views
After I getting a set-cookie in response, is not saved and transmitted in requests
Basically after an auth, I setting a cookie, but apparently after page refresh on the cookie that was set by cloudflare is saved
And the cookie that I transmitted with set-cookie is not used in after ...
0
votes
0answers
255 views
How to create api routes with Fastify and Nuxt?
Fastify changed a lot since the last time I played with it. Also, I read that we should use Nuxt serverMiddleware to add api routes but I couldn't find any example on how to proceed.
Below there is ...
0
votes
1answer
369 views
Error using fastify-multer to upload images
I am trying to use the fastify-multer plugin to upload files to the server and I am able to successfully get the images uploaded to the folder.
The problem is my app crashes.
I used the fastify-cli ...
0
votes
1answer
64 views
Traefik 502 bad gateway | Wrong config? | fastify nextjs
I have an auth service (node.js backend, fastify), nextjs service that serves SSR react app and traefik acting as a reverse proxy in front.
With the current config the app is served correctly, but I'm ...
0
votes
0answers
57 views
How to get random mongodb documents using aggregate() and $sample?
I am trying to get 2 random documents within a collection called 'templates' but I only get an Internal Server Error.
I have successfully tested the following code in the mongo shell:
db....
0
votes
2answers
173 views
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 ...
0
votes
1answer
48 views
ObjectionJS - Group models in a data layer file
I have a NodeJS app running fastify with fastify-objectionjs.
For tidiness, I'd like to group all models in a single file called _main.js, where I export an array of the models inside the models ...
1
vote
1answer
251 views
It's possible to get next.js request object globally?
I am using fastify with next.js and I need to include tracing (requestId is the problem so far). What I am doing right now is creating a fastify onRequest hook and generating a requestId value and ...
1
vote
0answers
59 views
Why error is being logged as info in GCP when using fastify logging?
We have configured Fastify to log as info using the following:
const fastify = require("fastify")({
logger: { level: process.env.LOG_LEVEL || "info" }
});
and from our Error handler we are logging ...
1
vote
1answer
135 views
controller don't return result without replay.send with fastify platform
I have login route, that return user:
@Post('login')
async login(@Body() user: LoginRequest, @Res() reply): Promise<User> {
const foundUser = await this.authService.validateUser(user.email, ...
0
votes
2answers
843 views
How to send file with fastify & nestjs?
I have the following front end middleware:
export class FrontendMiddleware implements NestMiddleware {
use(req: any, res: any, next: () => void) {
const url = req.originalUrl;
...
0
votes
1answer
207 views
Result perf node using mongo nestJs or fastify
I have made two projects, one using nestJS/mongoDB and the other Fastify/MongoDB in order to compare performance of both frameworks. I made a simple get resource API querying a mongo document having ~...
0
votes
1answer
189 views
How to mock this method?
I want to mock the below line of code. And please explain how I can mock this in detail as I'm new to javascript and writing test cases. The below code would return a promise.
const ...
2
votes
1answer
324 views
How to fix “not ok timeout!” when testing fastify route?
I am trying to test fastify route with tap. Here is the test file:
const tap = require('tap')
const buildFastify = require('../../src/app')
tap.test('GET `/` route', t => {
t.plan(4)
...
1
vote
1answer
818 views
NestJS set HttpStatus in interceptor
I'm using an interceptor to transform my response. I want to set the HttpStatus inside but the code I'm using now doesn't work.
import { CallHandler, ExecutionContext, NestInterceptor, SetMetadata } ...
0
votes
1answer
24 views
Couldn't catch(construct) the right router
I read https://github.com/fastify/fastify/blob/master/docs/Routes.md
But my router doesn't seems to catch the right url with params
Url : /app/name?id=666&method=3&_=1553342444710
I tried:...