Before trying to run the application, please rename .env.example
to .env
and config environmental variables.
If you want to run HTTP files from assets/api
, make sure to change http-client.env.json
SQL File (MariaDB) (assets/db.sql
)
Database visualization (assets/db.png
)
The json values are not sorted properly. I am very sorry for that :>
The process of acquiring an auth token consists of two POST requests to v1/auth
:
- Sending
["school", "nickname", "name"]
- Sending
["school", "nickname", "name", "code"]
, code is the demo code provided by the supervisor
Completed second request, you will receive token
.
Pass the token as a header parameter to every endpoint that needs authorization:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpb3QiOjE2MDIwOTM0ODksInVzZXIiOjF9.teHbsPmW4t65mtfwqhQhhDhkrM13EoQEcY2eK4dxr7E
Open endpoints require no Authentication.
GET
/v1/status
- API Status (Example | Code)GET
/v1/schools
- List of schools (Example | Code)GET
/v1/report_categories
- List of report Categories (Docs | Code)POST
/v1/auth
- Authentication (Example | Code)
GET
/v1/u/user
- User Information (name
,nickname
,school
,type
) (Example | Code)GET
/v1/u/school
- School information (list of students & name of the school) (Example | Code)GET
/v1/u/proposals
- List of proposals (Example | Code)POST
/v1/u/proposals_add
- Create a new proposal (Example | Code)
If something is wrong with your request or the server, you will get an error like this:
{
"ok": false
"error": "Key: 'Authorization' Error:Field validation for 'Authorization' failed on the 'required' tag",
"error_code": -2,
}
If error_code
is negative, the problem is on your side, you don't have to handle every error distinctly. If the code is positive - the error should be handled (there is something wrong with user's input).
The error
string is generated either by gin (when request is invalid) or specified directly in the code. It's not localized - localization should be done on the client.
-1
- invalid request (missing parameters or some problems with validation)
-2
- user does not exist-3
- user with this token does not exist2
- account is not verified/blocked (by the supervisor)