# install dependencies
npm install
# serve with hot reload
npm run dev
# serve for production
npm run start
# migrate the database from 0
npm run migrate- All endpoints return a JSON object with the following format
// If everything went ok
{
data: [{...}],
error: null
}
// In case of an error occours
{
data: null,
error: "Error message"
}- HTTP
400return code is used for malformed requests; the issue is on the sender's side. - HTTP
401return code is used when trying to access a protected endpoint without providing a JWT. - HTTP
403return code is used when trying to access a protected endpoint with an invalid JWT. - HTTP
500return code is used for internal errors; the issue is on the API side.
POST /register
Registers a new user.
Parameters:
{
"email" : "[email protected]",
"name" : "Username",
"password" : "anypassword"
}Response:
{
"data": "Congratulation, you have successfully registered!",
"error": null
}POST /login
Returns a JWT for an existing user.
Parameters:
{
"email" : "[email protected]",
"password" : "validpassword"
}Response:
{
"data": {
"accessToken": "...",
"role": 0 // 0 for normal users, 1 for admin users
},
"error": null
}