Fastify/4/Url Params Optional

1.0.2Last update Aug 19, 2024
by@arshcodemod

This codemod declares the optional parameters explicitly.

🚦 Impact Level: Minimal

What Changed

If you've already used any implicitly optional parameters, you'll get a 404 error when trying to access the route. You will now need to declare the optional parameters explicitly.

Before

fastify.get('/posts/:id', (request, reply) => {
const { id } = request.params;
});

After

fastify.get('/posts/:id?', (request, reply) => {
const { id } = request.params;
});

Build custom codemods

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

background illustrationGet Started Now