Fastify/5/Decorate Request To Getter Method

/icons/calendar.svg

Last update

Sep 17, 2024

This codemod transforms fastify.decorateRequest with static objects into the new Fastify v5 pattern using a getter function.

Before

fastify.decorateRequest('myObject', { hello: 'world' });

After

fastify.decorateRequest('myObject', {
getter() {
return { hello: 'world' };
},
});

This shows the transition from decorating requests with static objects to using a getter method in Fastify v5, which allows for more dynamic and flexible request decorations.

Build custom codemods

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

background illustrationGet Started Now