Skip to main content
PRONeed enterprise-grade codemods tailored to your codebase?

Assess, plan, evolve.

Reusable compiler-aware skills that help coding agents understand, plan, and safely evolve your codebase.

21 packages

Sort by
fastify/4/remove-app-use

This codemod removes app.use() and the use of middleware is no longer supported. 🚦 **Impact Level**: Minimal ## What Changed With v4 of Fastify, app.use() has been removed and the use of middleware is no longer supported. If you need to use middleware, use @fastify/middie or @fastify/express, which will continue to be maintained. However, it is strongly recommended that you migrate to Fastify's hooks. ## Before ```jsx const fastify = require('fastify')(); fastify.use((req, res, next) => { console.log('Middleware executed'); next(); }); fastify.get('/example', (req, res) => { res.send('Hello, World!'); }); fastify.listen(3000, () => { console.log('Server is running on http://localhost:3000'); }); ``` ## After ```jsx const fastify = require('fastify')(); const middie = require('@fastify/middie'); fastify.register(middie); fastify.use((req, res, next) => { console.log('Middleware executed'); next(); }); fastify.get('/example', (req, res) => { res.send('Hello, World!'); }); fastify.listen(3000, () => { console.log('Server is running on http://localhost:3000'); }); ```

  • fastify
  • 4
  • +1
Aarshcodemod
v1.0.4
1,154
a year ago
fastify/4/reply-raw-access

This codemod converts reply.res moved to reply.raw. 🚦 **Impact Level**: Minimal ## What Changed If you previously used the reply.res attribute to access the underlying Request object you will now need to use reply.raw. ## Before ```jsx fastify.get('/example', (request, reply) => { const rawResponse = reply.res; rawResponse.writeHead(200, { 'Content-Type': 'text/plain' }); rawResponse.end('Hello, World!'); }); ``` ## After ```jsx fastify.get('/example', (request, reply) => { const rawResponse = reply.raw; rawResponse.writeHead(200, { 'Content-Type': 'text/plain' }); rawResponse.end('Hello, World!'); }); ```

  • fastify
  • 4
  • +1
Aarshcodemod
v1.0.4
971
a year ago
fastify/5/migrationRecipe

This recipe provides a set of codemods designed to assist with migrating to Fastify 5. Each codemod addresses specific changes and enhancements introduced in Fastify 5. ### Included Codemods - **`fastify/5/req-params-hasOwnProperty-to-objectHasOwn`**: Converts `req.params.hasOwnProperty` to `Object.hasOwn`. - **`fastify/5/listen-arg-transformation`**: Updates the transformation of arguments passed to `listen`. - **`fastify/5/replace-hardcoded-url-in-hasroute`**: Replaces hardcoded URLs in `hasRoute` checks. - **`fastify/5/replace-reply-sent-with-hijack`**: Replaces `reply.sent` with `reply.hijack`. - **`fastify/5/add-expose-head-routes-option`**: Adds the `exposeHeadRoutes` option where necessary. - **`fastify/5/decorate-request-to-getter-method`**: Converts request decorators to getter methods. - **`fastify/5/route-schema-enhancement`**: Enhances route schemas with new features. - **`fastify/5/req-connection-to-socket`**: Converts `req.connection` to `req.socket`. - **`fastify/5/getResponseTime-to-elapsedTime`**: Renames `getResponseTime` to `elapsedTime`. - **`fastify/5/redirect-arg-order`**: Updates the argument order for `redirect`. - **`fastify/5/make-reply-trailer-async`**: Converts `reply.trailer` to an async method. - **`fastify/5/remove-done-callback`**: Changes `plugin.register` from `done` callback to `return`. - **`fastify/5/rename-logger-to-logger-instance`**: Renames `logger` to `loggerInstance`. These codemods will help streamline your migration process and ensure compatibility with Fastify 5. ---

  • fastify
  • migration
Mmanishjha-04
v1.0.4
19
a year ago
fastify/4/migration-recipe

This recipe is a set of codemods that will help migrate to Fastify 4. The recipe includes the following codemods: - fastify/4/await-register-calls - fastify/4/expose-head-routes - fastify/4/remove-app-use - fastify/4/reply-raw-access - fastify/4/url-params-optional - fastify/4/wrap-routes-plugin

  • fastify
  • migration
Aarshcodemod
v1.0.4
61
a year ago
fastify/4/expose-head-routes

This codemod introduces the `exposeHeadRoutes: false` option to avoid automatic `HEAD` route exposure, while keeping manually defined `HEAD` routes intact. ### Before ```ts fastify.get('/route', {}, (req, reply) => { reply.send({ hello: 'world' }); }); fastify.head('/route', (req, reply) => { // ... }); ``` ### After ```ts fastify.get( '/route', { exposeHeadRoutes: false, }, (req, reply) => { reply.send({ hello: 'world' }); }, ); fastify.head('/route', (req, reply) => { // ... }); ``` ---

  • fastify
  • 4
  • +1
Aarshcodemod
v1.0.4
1,162
a year ago
fastify/5/redirect-arg-order

This codemod updates `reply.redirect` by placing the status code as the second argument, as per Fastify v5 conventions. ### Before ```ts reply.redirect(301, '/new-route'); ``` ### After ```ts reply.redirect('/new-route', 301); ``` ---

  • fastify
  • 5
  • +1
Mmanishjha-04
v1.0.4
290
a year ago
fastify/4/wrap-routes-plugin

This codemod wrap your routes in a plugin 🚦 **Impact Level**: Minimal ## What Changed To improve error reporting in route definitions, route registration is now synchronous. As a result, if you specify an onRoute hook in a plugin you should wrap your routes in a plugin. ## Before ```jsx fastify.register((instance, opts, done) => { instance.addHook('onRoute', (routeOptions) => { const { path, method } = routeOptions; console.log({ path, method }); done(); }); }); fastify.get('/', (request, reply) => { reply.send('hello') }); ``` ## After ```jsx fastify.register((instance, opts, done) => { instance.addHook('onRoute', (routeOptions) => { const { path, method } = routeOptions; console.log({ path, method }); done(); }); }); fastify.register((instance, opts, done) => { instance.get('/', (request, reply) => { reply.send('hello') }); done(); }); ```

  • fastify
  • 4
  • +1
Aarshcodemod
v1.0.4
119
a year ago
fastify/4/url-params-optional

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 ```jsx fastify.get('/posts/:id', (request, reply) => { const { id } = request.params; }); ``` ## After ```jsx fastify.get('/posts/:id?', (request, reply) => { const { id } = request.params; }); ```

  • fastify
  • 4
  • +1
Aarshcodemod
v1.0.2
577
a year ago
fastify/4/await-register-calls

This codemod helps to improve error reporting in route definitions, route registration is now synchronous, so if you specify an onRoute hook in a plugin, you should now use await.register() ## What Changed To improve error reporting in route definitions, route registration is now synchronous. As a result, if you specify an onRoute hook in a plugin you should now use await.register() ## Before ```jsx fastify.register((instance, opts, done) => { instance.addHook('onRoute', (routeOptions) => { const { path, method } = routeOptions; console.log({ path, method }); }); done(); }); ``` ## After ```jsx await fastify.register((instance, opts, done) => { instance.addHook('onRoute', (routeOptions) => { const { path, method } = routeOptions; console.log({ path, method }); }); done(); }); ```

  • fastify
  • 4
  • +1
Aarshcodemod
v1.0.4
1,171
a year ago
fastify/5/remove-done-callback

This codemod updates `fastify.register` to use `return` instead of `done`, reflecting changes in Fastify v5 for asynchronous plugin registration. ### Before ```ts fastify.register(async function(instance, opts, done) { done(); }); ``` ### After ```ts fastify.register(async function(instance, opts) { return; }); ``` ---

  • fastify
  • 5
  • +1
Mmanishjha-04
v1.0.4
129
a year ago
fastify/5/rename-logger-to-logger-instance

This codemod updates the Fastify logger configuration by renaming the `logger` option to `loggerInstance`, in line with Fastify v5 changes. ### Before ```ts const logger = require('pino')(); const fastify = require('fastify')({ logger, }); ``` ### After ```ts const loggerInstance = require('pino')(); const fastify = require('fastify')({ loggerInstance, }); ``` --- This example shows how the codemod modifies the logger option to `loggerInstance`, aligning with the updated configuration practices in Fastify v5.

  • fastify
  • 5
  • +1
Mmanishjha-04
v1.0.4
35
a year ago
fastify/5/route-schema-enhancement

This codemod enhances the schema definition for query strings by converting it to the full object schema format, adding properties and required fields. ### Before ```ts fastify.get( '/route', { schema: { querystring: { name: { type: 'string' }, }, }, }, (req, reply) => { reply.send({ hello: req.query.name }); }, ); ``` ### After ```ts fastify.get( '/route', { schema: { querystring: { type: 'object', properties: { name: { type: 'string' }, }, required: ['name'], }, }, }, (req, reply) => { reply.send({ hello: req.query.name }); }, ); ``` --- This illustrates how the codemod updates query string schema definitions in Fastify v5 to the more detailed object schema format, ensuring proper validation.

  • fastify
  • 5
  • +1
Mmanishjha-04
v1.0.4
351
a year ago

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.