The Best is a tiny and simple ranking API.
- NodeJS
- MongoDB
At first, clone this repository to your computer:
https://github.com/lai32290/theBest
Then you can just edit the path where you want to keep your MongoDB file to volumes
option in docker-compose.yml
file.
Sample:
mongo:
image: mongo
volumes:
- {your-db-path}:/var/db
ports:
- 27017:27017
restart: always
container_name: theBestMongo
Then just execute docker-compose up -d
and test it accessing on localhost/status
(GET).
Then you can edit your environment configuration in the settings.json
file and execute node server.js
, then test it accessing on localhost/status
(GET).
Check if the API is working.
No parameters required
{
"status" : "success",
"statusCode" : 1,
"data" : {
"message" : "The Best is On!"
}
}
Register a new application in the service and returing a hash to use in other requests.
name
: The name of application
{
"status" : "success",
"statusCode" : 1,
"data" : {
hash : '82267be7b55d204e0f996fa0a09a37890df2a9e1'
}
}
Get the top rankings.
{ app_hash: '82267be7b55d204e0f996fa0a09a37890df2a9e1', [top_limit: 10] }
app_hash
: The hash returned in/app/new
top_limit
: How much tops of the ranking do you want to get. (optional)
{
"status": "success",
"statusCode": 1,
"data": [
{
"_id": "591500e5ef62b9000167c795",
"id": "360f529932aa6142d91870b5",
"bestScore": 567
}
]
}
Register a new score to the player
user_id
: The user identification, you can use your role to define the identification, the API will just use it to recover the user scores.app_hash
: The hash returned by/app/new
request.
{
"status" : "success",
"statusCode" : 1,
"data" : {
"id": "590f529976aa6142d91870b7",
"appHash": "82267be7b55d204e0f996fa0a09a37890df2a9e1",
"scores": [100, 200, 150, 30, 25, 0, 63]
}
}
Return all scores of a specifically user.
user_id
: The user identification, you can use your role to define the identification, the API will just use it to recover the user scores.app_hash
: The hash returned by/app/new
request.
{
"status" : "success",
"statusCode" : 1,
"data" : {
"scores" : [100, 200, 300]
}
}
Return best score of a specifically user.
user_id
: The user identification, you can use your role to define the identification, the API will just use it to recover the user scores.app_hash
: The hash returned by/app/new
request.
{
"status" : "success",
"statusCode" : 1,
"data" : {
"score" : 1000
}
}