docs: update endpoints to use file-routing approach (#5397)

- Move the original guides for creating endpoints and middlewares to sub-sections in the Endpoints category.
- Replace existing guides for endpoints and middlewares with the new approach.
- Update all endpoints-related snippets across docs to use this new approach.
This commit is contained in:
Shahed Nasser
2023-10-19 18:56:26 +03:00
committed by GitHub
parent b38f73726d
commit c28935b4e8
170 changed files with 3658 additions and 3344 deletions

View File

@@ -46,7 +46,7 @@ If you follow the Medusa React code blocks, it's assumed you already have [Medus
### Authenticated Admin User
Except for the Accept Invite endpoint, you must be an authenticated admin user before following along with the steps in the tutorial.
Except for the Accept Invite API Route, you must be an authenticated admin user before following along with the steps in the tutorial.
You can learn more about [authenticating as an admin user in the API reference](https://docs.medusajs.com/api/admin#authentication).
@@ -54,7 +54,7 @@ You can learn more about [authenticating as an admin user in the API reference](
## List Invites
You can list invites by sending a request to the [List Invite endpoint](https://docs.medusajs.com/api/admin#invites_getinvites):
You can list invites by sending a request to the [List Invite API Route](https://docs.medusajs.com/api/admin#invites_getinvites):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -117,15 +117,15 @@ curl -L -X GET '<BACKEND_URL>/admin/invites' \
</TabItem>
</Tabs>
This endpoint does not accept any parameters.
This API Route doesn't accept any parameters.
The request returns an array of invite endpoints.
The request returns an array of invite objects.
---
## Create Invite
You can create an invite by sending a request to the [Create Invite endpoint](https://docs.medusajs.com/api/admin#invites_postinvites):
You can create an invite by sending a request to the [Create Invite API Route](https://docs.medusajs.com/api/admin#invites_postinvites):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -200,7 +200,7 @@ curl -L -X POST '<BACKEND_URL>/admin/invites' \
</TabItem>
</Tabs>
This endpoint requires the following body parameters:
This API Route requires the following body parameters:
- `user`: a string indicating the email of the user.
- `role`: a string indicating the role of the user. Its values can be `admin`, `member`, and `developer`.
@@ -213,7 +213,7 @@ The request does not return any data. If the invite was created successfully, th
A logged-out user can accept an invite, which would create a user for that user.
You can accept an invite by sending a request to the [Accept Invite endpoint](https://docs.medusajs.com/api/admin#invites_postinvitesinviteaccept):
You can accept an invite by sending a request to the [Accept Invite API Route](https://docs.medusajs.com/api/admin#invites_postinvitesinviteaccept):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -303,7 +303,7 @@ curl -L -X POST '<BACKEND_URL>/admin/invites/accept' \
</TabItem>
</Tabs>
This endpoint requires the following request body parameters:
This API Route requires the following request body parameters:
- `token`: a string indicating the invitations token.
- `user`: an object that has the following properties:
@@ -317,7 +317,7 @@ The request does not return any data. If the invite was accepted successfully, t
## Resend an Invite
You can resend an invite if its not accepted yet. To resend an invite, send a request to the [Resend Invite endpoint](https://docs.medusajs.com/api/admin#invites_postinvitesinviteresend):
You can resend an invite if its not accepted yet. To resend an invite, send a request to the [Resend Invite API Route](https://docs.medusajs.com/api/admin#invites_postinvitesinviteresend):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -374,15 +374,15 @@ curl -L -X POST '<BACKEND_URL>/admin/invites/<INVITE_ID>/resend' \
</TabItem>
</Tabs>
This endpoint requires the invite ID as a path parameter.
This API Route requires the invite ID as a path parameter.
The request does not return any data. If the invite was resent successfully, the status code of the response will be `200`.
The request doesn't return any data. If the invite was resent successfully, the status code of the response will be `200`.
---
## Delete an Invite
You can delete an invite by sending a request to the [Delete Invite endpoint](https://docs.medusajs.com/api/admin#invites_deleteinvitesinvite):
You can delete an invite by sending a request to the [Delete Invite API Route](https://docs.medusajs.com/api/admin#invites_deleteinvitesinvite):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -439,7 +439,7 @@ curl -L -X DELETE '<BACKEND_URL>/admin/invites/<INVITE_ID>' \
</TabItem>
</Tabs>
This endpoint requires the invite ID as a path parameter.
This API Route requires the invite ID as a path parameter.
It deletes the invite and returns the following fields:

View File

@@ -42,7 +42,7 @@ If you follow the Medusa React code blocks, it's assumed you already have [Medus
### Authenticated Admin User
Aside from the User Login and Reset Password steps, other endpoints require you to be an authenticated admin user.
Aside from the User Login and Reset Password steps, other API Routes require you to be an authenticated admin user.
You can learn more about [authenticating as an admin user in the API reference](https://docs.medusajs.com/api/admin#authentication).
@@ -52,7 +52,7 @@ You can learn more about [authenticating as an admin user in the API reference](
### User Login
You can log in a user by sending a request to the [User Login endpoint](https://docs.medusajs.com/api/admin#auth_postauth):
You can log in a user by sending a request to the [User Login API Route](https://docs.medusajs.com/api/admin#auth_postauth):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -126,7 +126,7 @@ curl -L -X POST '<BACKEND_URL>/admin/auth' \
</TabItem>
</Tabs>
This endpoint requires the following request body parameters:
This API Route requires the following request body parameters:
- `email`: a string indicating the users email.
- `password`: a string indicating the users password.
@@ -135,7 +135,7 @@ The request returns the logged-in user as an object.
### User Logout
You can log out a user by sending a request to the [User Logout endpoint](https://docs.medusajs.com/api/admin#auth_deleteauth):
You can log out a user by sending a request to the [User Logout API Route](https://docs.medusajs.com/api/admin#auth_deleteauth):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -192,15 +192,15 @@ curl -L -X DELETE '<BACKEND_URL>/admin/auth' \
</TabItem>
</Tabs>
The endpoint does not require any path or query parameters.
The API Route doesn't require any path or query parameters.
The request does not return any data. The response code will be `200` for successful log out.
The request doesn't return any data. The response code will be `200` for successful log out.
---
## Retrieve User Profile Details
You can retrieve the current users details for their profile by sending a request to the [Get Current User endpoint](https://docs.medusajs.com/api/admin#auth_getauth):
You can retrieve the current users details for their profile by sending a request to the [Get Current User API Route](https://docs.medusajs.com/api/admin#auth_getauth):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -256,7 +256,7 @@ curl -L -X GET '<BACKEND_URL>/admin/auth' \
</TabItem>
</Tabs>
This endpoint does not require any parameters.
This API Route doesn't require any parameters.
The request returns the current user as an object.
@@ -264,7 +264,7 @@ The request returns the current user as an object.
## Update Users Profile Details
You can update a users details in their profile by sending a request to the [Update User endpoint](https://docs.medusajs.com/api/admin#users_postusersuser):
You can update a users details in their profile by sending a request to the [Update User API Route](https://docs.medusajs.com/api/admin#users_postusersuser):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -338,7 +338,7 @@ curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \
</TabItem>
</Tabs>
This endpoint requires the ID of the user as a path parameter.
This API Route requires the ID of the user as a path parameter.
In the request body, you can pass any of the users fields that you want to update as a parameter. In the example above, you pass the `first_name` parameter to update the users first name. You can refer to the [API reference](https://docs.medusajs.com/api/admin#users_postusersuser) to learn about other available parameters.
@@ -360,7 +360,7 @@ Sending the password reset email is not handled by default in the Medusa backend
:::
You can request a password reset by sending a request to the [Request Password Reset endpoint](https://docs.medusajs.com/api/admin#users_postusersuserpasswordtoken):
You can request a password reset by sending a request to the [Request Password Reset API Route](https://docs.medusajs.com/api/admin#users_postusersuserpasswordtoken):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -430,7 +430,7 @@ curl -L -X POST '<BACKEND_URL>/admin/users/password-token' \
</TabItem>
</Tabs>
This endpoint requires the `email` parameter in the request body, which is the email of the user requesting to reset their password.
This API Route requires the `email` parameter in the request body, which is the email of the user requesting to reset their password.
The request does not return any data. The response code will be `204` if the request was processed successfully.
@@ -438,7 +438,7 @@ The request does not return any data. The response code will be `204` if the req
After the user resets their password and, typically, receives an email with a link to reset their password, they should enter their new password. The new password, along with the token passed to this page are used to reset the password on the Medusa backend.
You can reset the password by sending a request to the [Reset Password endpoint](https://docs.medusajs.com/api/admin#users_postusersuserpassword):
You can reset the password by sending a request to the [Reset Password API Route](https://docs.medusajs.com/api/admin#users_postusersuserpassword):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -512,7 +512,7 @@ curl -L -X POST '<BACKEND_URL>/admin/users/reset-password' \
</TabItem>
</Tabs>
This endpoint requires the following request body parameters:
This API Route requires the following request body parameters:
- `token`: a string indicating the password reset token.
- `password`: a string indicating the new password for the user.

View File

@@ -53,7 +53,7 @@ You can learn more about [authenticating as an admin user in the API reference](
## List Users
You can retrieve users in a store by sending a request to the [List Users endpoint](https://docs.medusajs.com/api/admin#users_getusers):
You can retrieve users in a store by sending a request to the [List Users API Route](https://docs.medusajs.com/api/admin#users_getusers):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -116,7 +116,7 @@ curl -L -X GET '<BACKEND_URL>/admin/users' \
</TabItem>
</Tabs>
This endpoint does not require any parameters.
This API Route doesn't require any parameters.
The request returns an array of user objects.
@@ -124,7 +124,7 @@ The request returns an array of user objects.
## Create a User
You can create a user by sending a request to the [Create User endpoint](https://docs.medusajs.com/api/admin#users_postusers):
You can create a user by sending a request to the [Create User API Route](https://docs.medusajs.com/api/admin#users_postusers):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -199,12 +199,12 @@ curl -L -X POST '<BACKEND_URL>/admin/users' \
</TabItem>
</Tabs>
This endpoint requires the following request body parameters:
This API Route requires the following request body parameters:
- `email`: a string indicating the email of the user.
- `password`: a string indicating the password of the user.
The endpoint accepts other optional body parameters, such as first name or last name. Check the [API reference](https://docs.medusajs.com/api/admin#users_postusers) for details on optional body parameters.
The API Route accepts other optional body parameters, such as first name or last name. Check the [API reference](https://docs.medusajs.com/api/admin#users_postusers) for details on optional body parameters.
The request returns the created user as an object.
@@ -212,7 +212,7 @@ The request returns the created user as an object.
## Update User
You can update a users details by sending a request to the [Update User endpoint](https://docs.medusajs.com/api/admin#users_postusersuser):
You can update a users details by sending a request to the [Update User API Route](https://docs.medusajs.com/api/admin#users_postusersuser):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -283,7 +283,7 @@ curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \
</TabItem>
</Tabs>
This endpoint requires the ID of the user as a path parameter.
This API Route requires the ID of the user as a path parameter.
In the request body, you can pass any of the users fields that you want to update as parameters. In the example above, you update the users `first_name`. Check the [API reference](https://docs.medusajs.com/api/admin#users_postusersuser) for all the optional parameters.
@@ -293,7 +293,7 @@ The request returns the updated user as an object.
## Delete a User
You can delete a user by sending a request to the [Delete User endpoint](https://docs.medusajs.com/api/admin#users_deleteusersuser):
You can delete a user by sending a request to the [Delete User API Route](https://docs.medusajs.com/api/admin#users_deleteusersuser):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
@@ -350,7 +350,7 @@ curl -L -X DELETE '<BACKEND_URL>/admin/users/<USER_ID>' \
</TabItem>
</Tabs>
This endpoint requires the user ID as a path parameter.
This API Route requires the user ID as a path parameter.
It deletes the user and returns the following fields: