-
Notifications
You must be signed in to change notification settings - Fork 0
API Backend Routes
stevenseb edited this page Sep 5, 2024
·
1 revision
User Authentication/Authorization
- Request : endpoints that require authentication
- Error Response: require authentication
- Status Code: 401
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Unauthorized”
}All endpoints that require authentication and the current user does not have the correct role or permissions
- Request: endpoints that require proper authorization
- Error Response: Require proper authorization
- Status Code: 403
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Forbidden”
}- Require Authentication: false
- Request Method: POST
- URL: /api/auth/login
- Headers:
- Content-Type: application/json
- Body:
{
“email”: “[john.smith@gmail.com](mailto:john.smith@gmail.com)”,
“password”: “secret”
}- Successful Response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Body:
- Headers:
{
“user”: {
“id”: 1,
“email”: “[john.smith@gmail.com](mailto:john.smith@gmail.com)”
“username”: “JSmith24”
}- Error Response: Invalid Credentials
- Status Code: 401
- Headers:
- Content-Type: application/json
- Body:
- Headers:
{
“Message”: “Invalid Credentials”
}- Error Response: Body validation errors
- Status Code 400
- Headers:
- Content-Type: application/json
- Body:
- Headers:
{
“message”: “Bad Request”
“errors” : {
“credential” : “Email is required”,
“password” : “Password is required”
}
}- Require Authentication: false
- Request
- Method: POST
- URL: /api/auth/signup
- Headers:
- Content-Type: application/json
- Body:
{
“username”: “Demo-User”,
“email”: “demo@email.com”,
“password” : “secret100!”
}- Successful Response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Body:
- Headers:
{
“user” : {
“id” : 1,
“email” : “demo@email.com”,
“username” : “Demo-User”
}
}- Error Response: User already exists with the specified email
- Status Code: 500
- Headers:
- Content-Type: application/json
- Body:
- Headers:
{
“message”: “User already exists”,
“errors”: {
“email”: “User with that email already exists”
}
}- Error Response: User already exists with the specified username
- Status Code: 500
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “User already exists”,
“errors”: {
“email”: “User with that username already exists”
}
}- Error Response: Body validation errors
- Status Code 400
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Bad Request”
“errors” : {
“email”: ‘Invalid email,
“username”: “Username is required”
“password” : “Password is required”
}
}
```js
#
## Get all Boards owned by the Current User
### Return all the boards owned by the current user
* Require Authentication: true
* Request
* Method: GET
* URL: /api/boards/current
* Body: none
* Successful Response
* Status Code: 200
* Headers:
* Content-Type: application/json
* Body:
```js
{
“Boards”: [
{
‘id’: 1,
“owner_id”; 1,
“name”: “my-first-board”,
“description”: “The first of many boards to be made”,
“created_at”: “YYYY-DD-MM”“,
“updated_at”: “YYYY-DD-MM”
}
]
}*Require Authentication: true *Request *Method: GET *URL: '/api/boards/int:id *Body: none
* Successful Response
* Status Code: 200
* Headers:
* Content-Type: application/json
* Body:
{
‘id’: 1,
“owner_id”; 1,
“name”: “my-first-board”,
“description”: “The first of many boards to be made”,
“created_at”: “YYYY-DD-MM”“,
“updated_at”: “YYYY-DD-MM”
}- Require Authentication: true
- Request: POST
- URL: /api/boards
- Headers:
- Content-Type: application/json
- Body:
- Request: POST
{
“owner_id”: 1,
“name”: “new board”,
“description”: “a new description”
}- Successful Response
- Status Code: 201
- Headers:
- Content-Type: application/json
- Body:
{
“id”: 1,
“owner_id”: 1,
“name”: “new board”,
“description”: “a new description”.
“created_at”: “YYYY-MM-DD”
“updated_at”: “YYYY-MM-DD”
}- Error Response
- Status Code: 400
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Bad Request”,
“errors”: {
“Name”: “Name is required”
}
}- Require Authentication: true
- Require Proper authorization: Board must belong to the user
- Request
- Method: PUT
- URL: /api/boards/int:id
- Headers:
- Content-Type: application/json
- Body:
- Request
{
“name”: “updated name”,
“description”: “updated description”
}- Successful Response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Headers:
- Body:
- Status Code: 200
{
“id”: 1,
“owner_id”: 1,
“name”: “updated name”,
“description”: “updated description”.
“created_at”: “YYYY-MM-DD”
“updated_at”: “YYYY-MM-DD”
}- Error Response: Body validation errors
- Status Code: 400
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Bad Request”,
“errors”: {
“Name”: “Name is required”
}
}- Error Response: Couldn’t find board with the specific id
- Status Code: 404
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Board couldn’t be found”
}-
Require Authentication: true
- Require proper authorization: Board must belong to the current user
-
Request
- Method: DELETE
- URL: /api/boards/int:id Body: none
-
Successful Response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Successfully deleted”
}- Error response: Couldn’t find a Board with the specified id
- Status Code: 404
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Board couldn’t be found”
}- Require authentication: true
- Request
- Method: POST
- URL: /api/boards/int:id/users
- Headers:
- Content-Type: application/json
- Body:
- Request
{
“board_id”: 1,
“user_id” : 1
}- Successful response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Body:
{
“id”: 1,
“board_id”: 1,
“user_id”: 1,
“created_at”: “YYYY-MM-DD”
“updated_at”: “YYYY-MM-DD”
}- Error response: Couldn’t find a Board with the specified id
- Status Code: 404
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Board couldn’t be found”
}-
Require Authentication: true
- Request:
- Method: GET
- URL: /api/boards/int:id/lists
- Body: none
- Request:
-
Successful Response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Body:
{
“Lists” : [
{
‘id’: 1,
‘name’: ‘first list’
‘board_id’: 1,
‘created_at’: ‘YYYY-MM-DD’
‘updated_at’: ‘YYYY-MM-DD’
}
]
}- Require Authentication: true
- Request: POST
- URL: /api/boards/int:id/lists
- Headers:
- Content-Type: application/json
- Body:
- Request: POST
{
‘name’: ‘a new list’
‘board_id’: 1
}Successful Response Status Code: 201 Headers: Content-Type: application/json Body:
{
“id”: 1,
‘board_id’: 1
“name”: “a new list”,
“created_at”: “YYYY-MM-DD”
“updated_at”: “YYYY-MM-DD”
}- Error Response: Body validation
- Status Code: 400
- Headers:
- Content-Type: application/json Body:
{
“message”: “Bad Request”,
“errors”: {
“Name”: “Name is required”
}
}- Require Authentication: true
- Request: PUT
- URL: /api/lists/int:id
- Headers:
- Content-Type: application/json
- Body:
{
‘name’: ‘updated list’
‘board_id’: 1
}- Successful Response
- Status Code: 201
- Headers:
- Content-Type: application/json
- Body:
{
“id”: 1,
‘board_id’: 1
“name”: “updated list”,
“created_at”: “YYYY-MM-DD”
“updated_at”: “YYYY-MM-DD”
}- Error Response: Body validation
- Status Code: 400
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Bad Request”,
“errors”: {
“Name”: “Name is required”
}
}-
Require Authentication: true
- Request
- Method: DELETE
- URL: /api/lists/int:id
-
Body: none
-
Successful Response
- Status Code: 200
- Headers:
- Content-Type: application/json
- Body:
{
“message”: “Successfully deleted”
}
Error response: Couldn’t find a List with the specified id
Status Code: 404
Headers:
Content-Type: application/json
Body:
{
“message”: “List couldn’t be found”
}