Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fastify route request and response handler type in Typescript

Anyone know what is the request and response handler type in fastify?

Now I am just using 'any', typescript eslint gave me a warning:

fastify.post('/ac', async(req: any , res: any) => {
like image 291
Alvin Avatar asked Jun 08 '26 00:06

Alvin


1 Answers

The appropriate types you're looking for are "FastifyRequest" and "FastifyReply", respectively.

They can be imported and implemented as shown below.

import { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';

fastify.post('/ac', async (req: FastifyRequest, res: FastifyReply) => {

});
like image 145
Arevi Avatar answered Jun 10 '26 19:06

Arevi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!