generated from agiledev-students-fall2023/generic-project-repository
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from agiledev-students-fall2023/sprint/2/spik…
…e/115/setup-api-docs added detailed documentation for the API endpoints
- Loading branch information
Showing
1 changed file
with
68 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,76 @@ | ||
# API Documentation | ||
The backend URL is set in the .env file. You can access it in your application using: | ||
|
||
#### Login API: | ||
- Endpoint /api/{userType}/login | ||
``` | ||
const BACKEND_BASE_URL = process.env.REACT_APP_BACKEND_URL; | ||
``` | ||
All API requests are made to: | ||
|
||
``` | ||
{backend-host-url}/api | ||
``` | ||
|
||
## Endpoints | ||
|
||
***Special Note for Request Body:*** | ||
|
||
Whenever multiple actions or data are being sent to the same API endpoint, ensure to include an ID in the request body. This ID will make it easier to filter and distinguish the intended action or data on the backend. | ||
|
||
### Login and Authentication | ||
Allows users (students or admins) to log in. | ||
|
||
URL: | ||
- Endpoint | ||
``` | ||
/{userType}/login | ||
``` | ||
- userType: "admin" or "student" | ||
- Method: POST | ||
- Request Body: | ||
- Method: POST | ||
|
||
Request Body: | ||
``` | ||
{ | ||
"email": "string", | ||
"password": "string" | ||
} | ||
``` | ||
``` | ||
|
||
### Issues Retrieval | ||
Allows retrieval of issues specific to a student or a department. | ||
|
||
URL: | ||
- Endpoint: | ||
``` | ||
/{userType}/issues/:paramName | ||
``` | ||
- userType: "admin" or "student" | ||
- paramName: Either studentName or deptName, depending on userType | ||
- Method: GET | ||
|
||
Request Body: | ||
``` | ||
// Not Implemented Yet | ||
// ID and issue number are a must | ||
``` | ||
|
||
### Actions | ||
Allows students or admins to perform actions like button presses, department changes, etc. | ||
|
||
***Important Note:*** | ||
|
||
Whenever an update is anticipated in the frontend due to an action, it should first be communicated and updated on the backend by sending a POST request to the actions endpoint. The frontend update should only occur as a consequence of the new data being fetched from the backend. This ensures that the frontend remains in sync with the backend's state, preserving data integrity and consistency across the application. | ||
|
||
URL: | ||
- Endpoint: | ||
``` | ||
/{userType}/actions/:paramName | ||
``` | ||
- userType: "admin" or "student" | ||
- paramName: Either studentName or deptName, depending on userType | ||
- Method: POST | ||
|
||
Request Body: | ||
``` | ||
// Not Implemented Yet | ||
// ID (and action type) must be present | ||
``` |