Fastify/5/Replace Hardcoded Url In Hasroute

1.0.0Last update Sep 17, 2024
by@manishjha-04

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