Questions tagged [fastify]

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

fastify
Filter by
Sorted by
Tagged with
0 votes
0 answers
54 views

register fastify swagger with helmet

i have this package version "@fastify/swagger": "^8.13.0", "@fastify/helmet": "^11.1.1", trying to register swagger into fastify app await app.register(import('...
user10596155's user avatar
0 votes
0 answers
28 views

Mocking dates within fastify when running jest tests

I have a fastify server with multiple endpoints and some of the endpoints use new Date() for getting the current date. For the most part I can get the date mocked to (for example) 2023/01/01 using ...
wuahi's user avatar
  • 39
0 votes
0 answers
55 views

Element implicitly has an 'any' type because expression of type '0' can't be used to index type

I'm not sure how to resolve this type script error: Element implicitly has an 'any' type because expression of type '0' can't be used to index type 'OkPacket | RowDataPacket[] | ResultSetHeader[] | ...
jebarpg's user avatar
  • 61
0 votes
0 answers
94 views

Post Request on fastify, content-lenght missing FastifyError "code":"FST_ERR_CTP_EMPTY_JSON_BODY"

I am sending a POST request without a 'Content-Length' header using Postman (body is not empty). On a Fastify Server, I am getting an error response like this: {"statusCode":400},"err&...
user1862965's user avatar
0 votes
0 answers
56 views

serving a static file from a calculated path

I have using @fastify/static v 6.12 to declare two different static paths like so import fastifyStatic from '@fastify/static'; fastify.register(fastifyStatic, { root: path.join(cwd(), 'public'...
punkish's user avatar
  • 14.4k
0 votes
0 answers
38 views

API calls don't work in Safari due to some SSL rule

I have an application in Full Stack format and I am facing some problems to perform the communication between the front end and the backend, the problem is that these errors are occurring exclusively ...
user avatar
0 votes
1 answer
38 views

NodeJS Fork Balancer

I have read one of the article long back for solving high memory usage task in a separate child process. Based on the article I have implemented the same and latency has been reduced. But currently ...
Srigar's user avatar
  • 1,678
0 votes
0 answers
49 views

Platformaticd db : adding custom object in entity data

In platformatic db, I have a entity. During get request I am trying to add additional key value to the object using entity hook and return the result. But in the response the custom key value is not ...
Prakash Arumugam's user avatar
0 votes
1 answer
236 views

How get access the unmodified body of a Fastify request

i'm using Fastify server with Zod validation schema, I aim to access the original, unaltered body of a Fastify request specifically to verify a signature in a webhook. Essentially, I want to examine ...
mima ouamen's user avatar
0 votes
1 answer
139 views

fastify rate limit based on condition

in my fastify project i would like to apply rate limit on some routes conditionally based on the validity of an api key. if the validate api function returns false, then limit. if returns true then ...
stefano manzi's user avatar
0 votes
0 answers
48 views

Fastify server doesn't update pages correctly

I'm working on an account system for a chat app I'm making, but the pages won't update. I can only get an updated page if I make an entirely new route for it. I'm using a serv00 server, and can't seem ...
Clover Johnson's user avatar
0 votes
0 answers
42 views

not able to retrieve jwt property on fastify instance

i'm here because i'm starting to get frustrated about fastify jwt implementation with typescript. This is my index.ts: import Fastify, { FastifyInstance } from 'fastify' import { config as ...
Gahrz90's user avatar
  • 87
0 votes
0 answers
30 views

ts-rest fastify server gets killed on ResponseValidationError

I am new to ts-rest and fastify. I setup a server as mentioned in the docs. this works fine. But I have the problem, that when I set responseValidation: true and have get a ResponseValidationError the ...
Roger's user avatar
  • 75
1 vote
1 answer
454 views

Is there a reason NOT to use Fastify (or Express) alone? [closed]

In starting a new Node project, I'm considering using Fastify by itself. Is this generally a bad decision? I've considered using Nest.js (which can incorporate either Fastify or Express) but is this ...
edcincy's user avatar
  • 331
0 votes
1 answer
131 views

create a fastify porject by fastify generate xxx. how move xxx to aws lambda

in local env, i need run "npm run dev" successfully after genereate a fastify project by fastify generate. I found npm run dev = fastify start -l info app.js. it refer to node_modules/...
davis du's user avatar
0 votes
0 answers
37 views

fastify-flash with typescript version

I am using https://github.com/fastify/fastify-flash for my cli generated typescript project but unable to use it. Getting below error whenever i am trying to use request.flash method. Property 'flash' ...
Ravi Roshan's user avatar
1 vote
1 answer
132 views

@fastify/cors issue giving me preflight 404

I have a very simple backend running with Fastify. This is my code: export class HttpServer { async start() { try { const fastify = Fastify(); await fastify....
jhnxx's user avatar
  • 93
0 votes
0 answers
185 views

How can I serialize and validate a request body that contains bigint in fastify with typebox?

I want to serialize and validate a request body that contains a bigint item with @sinclair/typebox as type provider. For example: const bodySchema = Type.Object({ currency: Type.String(), ...
Amirhossein Goli's user avatar
0 votes
0 answers
189 views

JWT verify Fastify

using fastify i am trying to add 2 types of JWT auth by using this code import fp from 'fastify-plugin'; import { FastifyInstance, FastifyRequest } from 'fastify'; import '@fastify/jwt'; declare ...
user10596155's user avatar
0 votes
1 answer
44 views

How to find sockets on other Nodejs server instances?

My server is set up so that once a socket connects, it stores that id of that socket and associates it with a user in a map like so: . . . const socketTracker = new Map(); io.on('connect', async (...
Mike K's user avatar
  • 6,077
0 votes
0 answers
28 views

How to initialize socket with a secure connection?

Currently, I have the following: // client . . . import { io } from 'socket.io-client'; . . . const socket = io('https://my_domain.com', { reconnectionDelay: 1000, reconnection: true, ...
Mike K's user avatar
  • 6,077
0 votes
0 answers
21 views

get the server's hostnme (not the request's hostname) [duplicate]

in a simple server like that, is there a way to get the server's hostname? let app = express() server.listen(3000, () => { let serverHostName = '???' }); note that, this is different ...
Sherif eldeeb's user avatar
0 votes
1 answer
288 views

fastify route handler not initiating after onRequest hook

i'm writing a fastify app that is supposed to listen for post requests and capture the raw body of the request for authentication purposes. Since i've searched far and wide for it it seems that ...
aporro's user avatar
  • 3
0 votes
1 answer
177 views

How can i set scope authorization for a route in fastify and check user has access to that route or not with Node.js

i want to put some paramter in authenticate method like this onRequest: [fastify.authenticate('scope')] but i dont know how can i implement that this is my code route fastify.post( "/", ...
mohazh's user avatar
  • 3
0 votes
1 answer
133 views

Piping a pdfkit PDF to Fastify

From what I've read, his should work. But it just downloads an empty document. So I must be handling the pipe incorrectly. It works fine if I pipe it to fs.createWriteStream instead... import ...
user4893295's user avatar
0 votes
0 answers
133 views

Unable to Access Custom Property in Fastify Request Object

I'm facing an issue with Fastify where I'm unable to access a custom property I've set in the request object. Here's a minimal example of my Fastify server setup: const app = Fastify(); app.use(async ...
user3362334's user avatar
  • 2,090
0 votes
0 answers
204 views

How can I set the cors in fastify server

I am using Fastify to build a backend API which I want to integrate with a React front end. I have tried registering Cors and its options using a variety of solutions available but nothing seems to ...
Dennis7456's user avatar
0 votes
1 answer
87 views

Issue verifying token via query param using FastifyJWT: TypeError - request.jwtVerify is not a function

The issue at hand revolves around the utilization of FastifyJWT for token verification in a Fastify application. Specifically, when attempting to perform the verification process on a token received ...
Thiago Kosudi's user avatar
0 votes
1 answer
299 views

Uploading files using multipart form to Shopify files using Fastify multi-part

I'm using Fastify-multipart v5.3.1 with fastify v3 (for compatibility reasons) I use it to upload files from the client to the server and then from the server to Shopify. From client to our server the ...
محمد خير الخلق's user avatar
0 votes
0 answers
16 views

How can I authenticate the JWT so that the information can only be accessed by logged in users? Using Node.js and Fastify

I'm new at Node.js and I need some help with my code. I'm developing an API-REST for diet control. My code is returning the JWT successfully when the person logs in, but now I don't know how to verify ...
Pedro Schinke's user avatar
0 votes
0 answers
67 views

Nestjs exception filter wont render handlebars html as response

I have this controller, which is successfully returning rendered, with handlebars, index.html for root path "/" @Controller() export class AppController { @Get() @Render("...
yory100's user avatar
  • 75
0 votes
0 answers
45 views

Problem with autocompletion of imports in typescript with custom paths

I want to create a folder called libs/shared/src, where there is shared stuff between projects, with the client, and the server. actually I created that folder and inside it is the libs/shared/src/...
Michael-Liendo's user avatar
0 votes
1 answer
91 views

React + Fastify unable to authorize logged in user

I use fastify session. I have a route in fastify that only allows logged in users to access. I tested it using Thunder Client in VS Code (its like Postman) and it works. I was able to access the route ...
MFS Craft's user avatar
0 votes
0 answers
54 views

Can't start app with Fastify-Vite and Redux-toolkit

I'm trying to make an app with Fastify and Vite. It works in dev mode (running npm run dev), but I get an error after trying to run npm start. node:internal/process/esm_loader:40 internalBinding(...
Maksim's user avatar
  • 260
0 votes
1 answer
350 views

NestJS e2e testing : Mocking Prisma client with Jest (fastify)

When making e2e tests, you probably want to mock your call to prisma, but it might be complicated with NestJS module to find a way of doing it properly For people looking for a proper exemple here is ...
Valentin's user avatar
  • 116
0 votes
1 answer
355 views

Unable to stream openAI response from a fastify server

I am banging my head against the wall with something which should be so very simple! Just to call the openAI API and return the stream from the fastify server. I have seen the docs and streams are ...
dendog's user avatar
  • 3,136
0 votes
2 answers
276 views

Fastify-cli with ES modules instead of CommonJS

I'm currently switching from CommonJS modules to ES modules and encountering some issues with my Fastify-Cli project. I'm using a custom logging module which I'm setting when running the command ...
chris's user avatar
  • 600
0 votes
0 answers
92 views

Fastify is giving me an error I cannot find where im fulfilling a promise with undefined

I set up a SSE endpoint on a simple Fastify project. This is the endpoint: app.get('/sse', async (_, res) => { res.raw.setHeader('Content-Type', 'text/event-stream') res.raw.setHeader('...
whyAmIStillWorking's user avatar
0 votes
0 answers
66 views

Submission error! response.header is not a function in nest-fastify graphql

I need set header autorization client. But have error in my Mutation "Submission error! response.header is not a function". my main.ts async function bootstrap() { const app = await ...
PovarCoda's user avatar
0 votes
0 answers
119 views

fastify schema cannot read nested objects

I have the following schema schema { "response": { "200": { "type": "object", "properties": { "data": { ...
Sherif eldeeb's user avatar
2 votes
1 answer
272 views

How to format fastify logs as logfmt

We have very strict rule: all microservices should write their logs using logfmt format. By default, fastify using json formatting. This is the only thing that stops us from using this framework. I ...
n0nvme's user avatar
  • 1,319
0 votes
0 answers
39 views

fastify searching data from postgresql

login.ejs has following code <input type="text" name="addUser_license" id="addUser_license" /> <!-- Display the search results --> <ul> <% ...
user3227899's user avatar
-2 votes
1 answer
117 views

How to resolve asynchronous function it's not returning data in time when fastify sends the request [duplicate]

Items in the first log does work while in the second log gives just empty array I guess it's because it's not loaded yet, how to fix I was trying async and await but nothing works const db = require(&...
Dexter's user avatar
  • 3
1 vote
0 answers
159 views

Typescript API contract, type instantiation is excessively deep and possibly infinite

I am trying to come up with a simple API contract similar to ts-rest, but strip away a lot of things I don't need. Also I want to use json schema instead of Zod. Most of the code is copied from ts-...
Manu's user avatar
  • 933
0 votes
1 answer
102 views

Erros in fastify lib using ajv

I receieve this errors when i build my typescript code node_modules/@fastify/ajv-compiler/types/index.d.ts(1,10): error TS2305: Module '"ajv"' has no exported member 'AnySchema'. ...
Jubileu's user avatar
  • 11
0 votes
0 answers
225 views

Where does secure-session store session data?

I've started using @fastify/secure-session in my app, and I can't find anything on the docs to say where it's storing data. I was planning to use redis, but it's not using that (yet). It can't be in ...
user4893295's user avatar
0 votes
1 answer
170 views

Property 'X' does not exist on type 'FastifyContext<unknown>'

I want to add the token: string field to the FastifyContext interface. For this purpose I have created the following file structure: projectDir |__src | |__@types | | |__fastify | | | |__index.d....
Prosto_Oleg's user avatar
1 vote
1 answer
360 views

How to customize an errors with Fastify, Ajv and Schema?

How can I customize an errors with Fastify, Ajv and Scheme? I need to format by: { "message": "Bad request", "path": "/account/register", "...
Igor Bezlepkin's user avatar
0 votes
0 answers
99 views

Testing with `Tap` never ends

I am using Tap with Fastify inject to test my Server implementation. If I run my test cases using yarn run test, it executes all the test and evaluates correctly. However, it never shuts down to show ...
Chilarai's user avatar
  • 1,872
0 votes
0 answers
506 views

Setting up an HTTP and HTTPS port in my Nest JS application with Fastify

The problem Hi, I have a local dockerized NestJS app over Fastify in my local machine. I want to configure an external third party service to push data on some endpoints in my app. My app is listening ...
Abeer's user avatar
  • 1

1
2
3 4 5
16