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(api): Add API routes page #474

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

Conversation

avj2352
Copy link
Contributor

@avj2352 avj2352 commented Jan 31, 2025

Checklist

Related issue

Fixes #433

Add documentation on API routes to Tuono Doc site

  • Provided example for GET & POST methods
  • Provided example for Request based JSON payload & Response based JSON payloads
  • Adds new page in tuono.dev doc site

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jan 31, 2025
@avj2352

This comment was marked as duplicate.

@avj2352

This comment was marked as spam.

@marcalexiei
Copy link
Member

marcalexiei commented Jan 31, 2025

CI is failing and PR title isn't following contributing guidelines.
Please, be so kind to fix it before asking for review / changes.
Once done you can mark the PR as "Ready for review"

Thanks

@marcalexiei marcalexiei marked this pull request as draft January 31, 2025 20:09
@avj2352 avj2352 changed the title [Documentation] Add API routes page [Documentation]: Add API routes page Feb 1, 2025
@avj2352 avj2352 marked this pull request as ready for review February 1, 2025 02:50
@avj2352 avj2352 changed the title [Documentation]: Add API routes page docs(api): Add API routes page Feb 1, 2025
@avj2352
Copy link
Contributor Author

avj2352 commented Feb 1, 2025

Apologies, my bad. I've fixed PR checks. please review

Copy link
Member

@Valerioageno Valerioageno left a 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: [
{
Copy link
Member

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.
Copy link
Member

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

Suggested change
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.
Copy link
Member

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

Suggested change
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.

Comment on lines +18 to +28
## 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)]
```
Copy link
Member

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

Suggested change
## 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)]
```

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

Successfully merging this pull request may close these issues.

[Documentation]: add /routing/api-routes page
3 participants