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: add examples for index.ts files on server routes #23390
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Run & review this pull request in StackBlitz Codeflow. |
✅ Live Preview ready!
|
Atinux
reviewed
Sep 25, 2023
Atinux
reviewed
Sep 25, 2023
Co-authored-by: Sébastien Chopin <seb@nuxtlabs.com>
Co-authored-by: Sébastien Chopin <seb@nuxtlabs.com>
Thanks @Atinux. I committed your suggestions. |
Atinux
approved these changes
Sep 27, 2023
Closed
DamianGlowala
added a commit
that referenced
this pull request
Sep 27, 2023
8 tasks
Merged
manniL
pushed a commit
that referenced
this pull request
Dec 11, 2023
Co-authored-by: Sébastien Chopin <seb@nuxtlabs.com> Co-authored-by: Sébastien Chopin <seb@nuxt.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
❓ Type of change
📚 Description
While getting to know how Nuxt handles server routes I stumbled over the required naming of the
.ts
files to create a rather common API structure:/api/project/
/api/project/[id]
/api/project/[id]/invite
The docs didn't convey that handling the "root" namespace of you API requires setting one (or multiple)
index.ts
files inside of theproject
directory so that/api/project
will be handled correctly and with potentially multiple HTTP verbs and different logic.This is obviously a quite common technique in all kinds of module-situations in the JS world but I thought it would be cool to include this as a short and concise example alongside the existing docs about the file router.
I am also aware that many things are more or less directly related to
nitro
and may or may not need to be directly documented inside the Nuxt docs but since this documentation is the first contact point for everyone learning Nuxt I though that I could help to make this more clear for all future learners!If you have any question or opinion about this, please ask straight away. I'd love to make this even better if needed. :)
📝 Checklist