Fastify/5/Req Params HasOwnProperty To ObjectHasOwn

1.0.2Last update Dec 17, 2024
by@manishjha-04

This codemod turns req.params.hasOwnProperty('name') into Object.hasOwn(req.params, 'name'), reflecting the new Fastify v5 approach to property checking.

Before

fastify.get('/route/:name', (req, reply) => {
console.log(req.params.hasOwnProperty('name')); // true
return { hello: req.params.name };
});

After

fastify.get('/route/:name', (req, reply) => {
console.log(Object.hasOwn(req.params, 'name')); // true
return { hello: req.params.name };
});

Build custom codemods

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

background illustrationGet Started Now