The server is written in Crystal to take advantages of the Ruby syntax and compiled performance. It uses Kemal to have as simple definitions of the endpoints as possible.
Responds with json object of a user like this:
{
"id": <id>,
"name": <name>,
"score": <total score>,
"achievements": [
{
"name": <achievement name>,
"description": <achievement desc>
},
...
],
"followers": [
{
"id": <follower id>,
"name": <follower name>
},
...
],
"following": [
{
"id": <followee 1 id>,
"name": <followee 1 name>
},
...
],
"leaderboards": [
{
"path": <path to leaderboard>,
"name": <leaderboard name (Global/Personal)>,
"type": <all_time/monthly/weekly>,
"rank": <rank number>,
"total": <number of participants>
},
...
],
}
Possible time frames:
- all_time
- monthly
- weekly Responds with a leaderboard that includes all users that (within the time frame) has a score larger than 0.
Possible time frames:
- all_time
- monthly
- weekly Responds with a leaderboard that includes all users followed by the user with userID = id (and the user itself).
All leaderboard endpoints respond with a json object of users' id, name and score sorted by score in descending order
[
{
user: {
id: <user id>,
name: <user name>
},
score: <1. place score>
},
...
]
Post a new contribution. The JSON object has to include user_id, type, changeset, score and date_time
{
"user_id": <user-id>,
"type": <id of type of contribution>,
"changeset": <id of changeset from OSM>,
"score": <points rewarded>,
"date_time": <ISO8601 format timestamp>
}
Add follows relationship such that user with id follows user with id .
Throws an error if or does not exist or if the relationship already exist.
Add a new user to the database with id and name .
Throws an error if already exist or if the name is more than 20 characters.
Deletes the follows relationship such that user with id no longer follows user with id .
Throws an error if the relation does not exist.