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

Refactor API Folder and Add Alias [skip percy] #943

Closed
wants to merge 2 commits into from

Conversation

mirhamasala
Copy link
Collaborator

📝 Description

This pull request introduces two key changes to improve the organization and clarity of the project's folder structure.

  1. The api folder has been renamed to _api to align with the existing naming convention for internal namespaces, such as _components, _utils, etc.
  2. A new path alias @/api/* has been added to the tsconfig.json file, pointing to src/app/_api/*. This simplifies imports and maintains consistency across the codebase.

Motivation

The change ensures that:

  • The folder structure remains consistent.

  • Developers can clearly identify internal namespaces.

  • Imports from the _api folder are easier to manage and understand.

  • Type: Refactor

🛠️ Key Changes

  • Renamed the api folder to _api in the src/app directory.
  • Updated tsconfig.json to include a new alias @/api/* pointing to src/app/_api/*.
  • Refactored existing imports to use the new alias @/api/* for consistency.

Setup

  1. Checkout the branch refactor/folder-structure-api-alias.
  2. Ensure all environment variables are correctly set (e.g., API keys in .env).

Steps to Test

  1. Run the project locally (npm run dev) and ensure all API endpoints still function as expected.
  2. Verify that imports from @/api/* resolve correctly in the following locations:
    • Services using _api.
    • Hooks dependent on API logic.
    • Any components/pages directly referencing _api functions.
  3. Build the project (next build) and ensure no errors occur.

Expected Results

  • API functionality remains unaffected.
  • No unresolved imports or build errors.
  • All tests pass successfully.

🔖 Resources

Copy link

vercel bot commented Dec 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
filecoin-foundation-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 19, 2024 3:08pm

@mirhamasala
Copy link
Collaborator Author

Closing because using _api for public endpoints will break functionality - the underscore prefix makes those routes inaccessible, as Next.js treats underscore-prefixed folders as private and won't generate public routes for them.

@mirhamasala mirhamasala deleted the mm/refactor-folder-structure-api branch December 30, 2024 17:15
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.

1 participant