This is a simple server that stores top scores for a game. This can be used with a simple JS app to create a web-based leaderboard.
git clone
npm install
The server can be started on port 3000 by running:
npm start
Returns a "pong".
{
"pong": "2018-09-04T23:59:53.199Z"
}
Returns an array containing the most recent game.
[
{
"id":"b1201649-db2e-4b31-9f86-628ef0bc0c54",
"timestamp":1536104977581,
"players": [
{"score":10,"name":"Incognito Porpoise"},
{"score":20,"name":"Unnamed Mule"},
{"score":30,"name":"UnsignedHippopotamus"}
]
}
]
Saves the given game data. At minimum the following should be sent in the request body:
{
"players": [
{
"score": 1,
}
]
}
If the data contains an id
that already exists, that data will overwrite the
previous data for that game. If no id
is present, one will be generated. The
timestamp
field will also be autofilled if it is missing. The same is true
for player names.
curl -s 'http://localhost:3000/games' -H 'Content-Type: application/json' --data-binary '{ "players": [ { "score": 10 }, { "score": 20 }, { "score": 30 } ] }'
Returns the top scores that have been recorded.
[
{"score":36,"name":"Incognito Cod"},
{"score":20,"name":"Unnamed Rabbit"},
{"score":10,"name":"Incognito Louse"}
]
This is released under the MIT license. See LICENSE.md for more information.