Fastify/5/Make Reply Trailer Async

/icons/calendar.svg

Last update

Sep 17, 2024

This codemod updates the reply.trailer method to use an async function for handling trailers, aligning with Fastify v5's support for asynchronous operations in trailers.

Before

fastify.get('/route', (req, reply) => {
reply.trailer('ETag', function(reply, payload) {
return 'custom-etag';
});
reply.send('');
});

After

fastify.get('/route', (req, reply) => {
reply.trailer('ETag', async function(reply, payload) {
return 'custom-etag';
});
reply.send('');
});

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now