Fastify/5/Replace Hardcoded Url In Hasroute

/icons/calendar.svg

Last update

Sep 17, 2024

This codemod highlights the shift in how routes with dynamic parameters should be referenced in fastify.hasRoute in Fastify v5.

Before

fastify.get('/example/:file(^\\d+).png', function(request, reply) {});
console.log(
fastify.hasRoute({
method: 'GET',
url: '/example/12345.png',
}),
);

After

fastify.get('/example/:file(^\\d+).png', function(request, reply) {});
console.log(
fastify.hasRoute({
method: 'GET',
url: '/example/:file(^\\d+).png',
}),
);

Build custom codemods

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

background illustrationGet Started Now