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

Docs: explain index files for server routing #2415

Closed
1 task done
geromegrignon opened this issue May 5, 2024 · 4 comments
Closed
1 task done

Docs: explain index files for server routing #2415

geromegrignon opened this issue May 5, 2024 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@geromegrignon
Copy link
Contributor

Describe the feature

The server routes documentation is missing a basic folder structure scenario, implying you are familiar with file-based routing structure.

It doesn't explain you can prefix files with index, like index.get.ts.

It unlocks using a folder for crud operations like:

articles
  - index.get.ts
  - index.post.ts
  - index.delete.ts

Or being able to cover routes like /articles and /articles/upcoming.

articles
  index.get.ts
  upcoming
    index.get.ts

Additional information

  • Would you be willing to help implement this feature?
@geromegrignon geromegrignon changed the title Docs: explain index.page.ts files Docs: explain index files for server routing May 5, 2024
@pi0 pi0 added documentation Improvements or additions to documentation and removed pending triage labels May 7, 2024
@pi0
Copy link
Member

pi0 commented May 7, 2024

PR more than welcome to improve nitro docs 🙏🏼

@geromegrignon
Copy link
Contributor Author

Awesome I wanted to wait for feedback from the team before starting working on it. I'll land a PR!

@ilyafish
Copy link

@geromegrignon please a PR would be huge for this!

Using your example, I had my routes configured like this:

src/api/v1
  - articles.get.ts
  - articles.post.ts
  - articles.delete.ts
src/api/v1/articles
  - upcoming.get.ts
  - upcoming.post.ts

It drove me crazy because I couldn't find any examples of doing this any other way while having a feeling it was possible and I was missing something. I only found this because my OCD finally had enough and I decided to spend an hour going through nearly every issue until I came across this.

@geromegrignon
Copy link
Contributor Author

Hi @ilyafish, sure I'll work on it tomorrow! Glad it already helped!

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

No branches or pull requests

3 participants