The react-scores-server
is the server-side app companion of react-scores
. It presents some APIs to perform CRUD operations on a student's university exams.
Hereafter, we report the designed HTTP APIs, also implemented in the project.
URL: /api/courses
Method: GET
Description: Get all the courses that the student needs to pass.
Request body: None
Response: 200 OK
(success) or 500 Internal Server Error
(generic error).
Response body: An array of objects, each describing a course.
[{
"code": "01TYMOV",
"name": " Information systems security ",
"CFU": 6
}, {
"code": "02LSEOV",
"name": " Computer architectures ",
"CFU": 10
},
...
]
URL: /api/courses/<code>
Method: GET
Description: Get the course identified by the code <code>
.
Request body: None
Response: 200 OK
(success), 404 Not Found
(wrong code), or 500 Internal Server Error
(generic error).
Response body: An object, describing a single course.
{
"code": "01TXYOV",
"name": "Web Applications I",
"CFU": 6
}
URL: /api/exams
Method: GET
Description: Get all the exams that the student already passed.
Request body: None
Response: 200 OK
(success) or 500 Internal Server Error
(generic error).
Response body: An array of objects, each describing an exam.
[{
"code": "02LSEOV",
"score": 25,
"date": "2021-02-01"
},
...
]
URL: /api/exams
Method: POST
Description: Add a new (passed) exam to the list of the student's exams.
Request body: An object representing an exam (Content-Type: application/json
).
{
"code": "01TXYOV",
"score": 30,
"date": "2021-05-04"
}
Response: 201 Created
(success) or 503 Service Unavailable
(generic error, e.g., when trying to insert an already existent exam). If the request body is not valid, 422 Unprocessable Entity
(validation error).
Response body: None
URL: /api/exams/<code>
Method: PUT
Description: Update entirely an existing (passed) exam, identified by its code.
Request body: An object representing the entire exam (Content-Type: application/json
).
{
"code": "01TXYOV",
"score": 31,
"date": "2021-05-04"
}
Response: 200 OK
(success) or 503 Service Unavailable
(generic error). If the request body is not valid, 422 Unprocessable Entity
(validation error).
Response body: None
URL: /api/exams/<code>
Method: DELETE
Description: Delete an existing (passed) exam, identified by its code.
Request body: None
Response: 204 No Content
(success) or 503 Service Unavailable
(generic error).
Response body: None