-
Notifications
You must be signed in to change notification settings - Fork 39
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(api): Add API routes page #474
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as spam.
This comment was marked as spam.
CI is failing and PR title isn't following contributing guidelines. Thanks |
Apologies, my bad. I've fixed PR checks. please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: With the documentation, we just have to highlight what the user can do (not drive them with a tutorial like page). Better to remove the all the examples and just give to the user a high level overview on the feature. The API reference
section will cover it with more details.
Please after the first overview section just write a simple example to show how to return an object with a GET request.
The page does not need to be long.
Thanks
@@ -106,6 +106,11 @@ export const sidebarElements: Array<SidebarElement> = [ | |||
label: 'Routing', | |||
href: '#focus', | |||
children: [ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please move this object to the end of the array so it is the one with the least priority within the Routing
section?
|
||
# API Routes | ||
|
||
Just like with [NextJS API routes ](https://nextjs.org/docs/pages/building-your-application/routing/api-routes). Tuono API routes provide a solution to build a public API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't reference Next.js
Just like with [NextJS API routes ](https://nextjs.org/docs/pages/building-your-application/routing/api-routes). Tuono API routes provide a solution to build a public API. | |
API routes provide a solution to build a public API with Tuono ⚡. | |
Any file inside the folder `src/routes/api` is mapped to `/api/*` path and will be treated as an API endpoint instead of a React route. |
|
||
Just like with [NextJS API routes ](https://nextjs.org/docs/pages/building-your-application/routing/api-routes). Tuono API routes provide a solution to build a public API. | ||
|
||
Any file inside the folder `src/routes/api` is mapped to the base url as `/api/*` and will be treated as an API endpoint instead of a page. They are server-side only bundles and won't increase your client-side bundle size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refined in the above comment
Any file inside the folder `src/routes/api` is mapped to the base url as `/api/*` and will be treated as an API endpoint instead of a page. They are server-side only bundles and won't increase your client-side bundle size. |
## HTTP Methods | ||
|
||
Tuono provides the following macros to define HTTP Request Methods | ||
|
||
```rs | ||
#[tuono_lib::api(GET)] | ||
#[tuono_lib::api(POST)] | ||
#[tuono_lib::api(PUT)] | ||
#[tuono_lib::api(PATCH)] | ||
#[tuono_lib::api(DELETE)] | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this section. Users can easily understand that only the HTTP methods can be passed to it with the example
## HTTP Methods | |
Tuono provides the following macros to define HTTP Request Methods | |
```rs | |
#[tuono_lib::api(GET)] | |
#[tuono_lib::api(POST)] | |
#[tuono_lib::api(PUT)] | |
#[tuono_lib::api(PATCH)] | |
#[tuono_lib::api(DELETE)] | |
``` |
Checklist
Related issue
Fixes #433
Add documentation on API routes to Tuono Doc site
tuono.dev
doc site