Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Route Handlers to Handle Caching in Next15 #1299

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

nishant2253
Copy link

📚 Description

This codemod refactors Route Handler files to manage caching behavior for GET functions. In the updated setup, GET methods are no longer cached by default. This codemod updates your Route Handler files to specify caching by adding the dynamic configuration option to routes requiring caching.

  1. Find Route Handlers: Identifies all GET functions in the Route Handler files.
  2. Property Check: Ensures the presence of GET functions and adds the dynamic configuration option where necessary.
  3. Add Caching Configuration: Inserts export const dynamic = 'force-static'; to enable caching for GET methods.
  4. Clean Up: Removes the experimental object if it is empty after the migration.

To run this codemod, run the following command in the project directory:
codemod Next/15/Update-Route-Handlers

🧪 Test Plan

Test the codemod by applying it to a specified repository to ensure that Route Handler files are updated correctly with the caching configuration. Verify that GET functions are correctly modified to include export const dynamic = 'force-static'; where needed and that there are no caching errors in the application.

  • Apply the codemod to the repository available at
    (https://github.com/imbhargav5/nextbase-nextjs-supabase-starter) and (https://github.com/nisabmohd/ChatGPT)

  • Could you confirm that all GET functions are updated to include the dynamic configuration for caching?

  • Test the application to ensure it functions correctly with the updated caching settings.

    All other test cases are run in the codemod studio and are present in /codemod/packages/codemods/next/15/route-handler-caching/textfixtures/.

📄 Documentation to Update

  • If applicable, update any relevant documentation to reflect changes in the caching behavior for GET functions. This may include README files or other developer guides that reference Route Handler caching strategies.

Copy link

vercel bot commented Aug 30, 2024

@nishant2253 is attempting to deploy a commit to the Codemod Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants