A simple (in-memory) leaderboard implemented in:
- Node.js
- Go
The leaderboard apis handle the following functionality:
Game management performs interaction with a defined leaderboard.
The API supports listing gameID Leaderboard entries.
The API uses the route signature /games/{id} where id is the gameID.
EXAMPLE:
curl -X GET http://localhost:8080/games/testThe API supports adding gameID Leaderboard point entries.
The API uses the route signature /points/{id} where id is the gameID.
EXAMPLE:
curl -X POST http://localhost:8080/points/test \
-H "Content-Type: application/json" \
-d '{ "game": "test", "name": "Rich", "score": 1000 }'EXPECTED OUTPUT
[{"game":"test","name":"Rich","score":1000}]The API supports deleting gameID Leaderboard.
The API uses the route signature /cancels/{id} where id is the gameID.
EXAMPLE:
curl -X DELETE http://localhost:8080/cancels/test#!/bin/bash
if [[ -z "$1" || -z "$2" ]]; then
echo "Usage: `basename "$0"` <GAME> <ENDPOINT>"
echo " Example: `basename "$0"` 'game1' 'https://api.example.com/game1'"
exit 1
fi
GAME="$1"
ENDPOINT="$2"
# Set the number of times to run the loop
NUM_ITERATIONS=5
for ((i=1; i<=NUM_ITERATIONS; i++)); do
curl -X POST "$ENDPOINT"/points/"$GAME" -H "Content-Type: application/json" -d '{ "game": "$GAME", "name": "tester-$i", "score": 1000 }'
sleep 5
doneData management performs import/export for a defined leaderboard.
Enable import of leaderboard from a JSON file.
curl -X POST -H "Content-Type: application/json" --data-binary @leaderboards.json http://localhost:8080/import
Enable export of leaderboard to a JSON file.
curl http://localhost:8080/export > leaderboards.json
EXPECTED OUTPUT
{"test":[{"game":"test","name":"Abby","score":1000},{"game":"test","name":"Bobby","score":1000},{"game":"test","name":"Catherine","score":1000},{"game":"test","name":"Derick","score":1000},{"game":"test","name":"Ernest","score":1000},{"game":"test","name":"Fred","score":1000},{"game":"test","name":"Gisele","score":1000},{"game":"test","name":"Harold","score":1000},{"game":"test","name":"Ivonne","score":1000},{"game":"test","name":"Jack","score":1000},{"game":"test","name":"Kelly","score":1000}]User management performs deletion of a specified user within a defined leaderboard.
The API supports deleting a user from the Leaderboard.
curl -X DELETE http://localhost:8080/remove/test/Rich



