Giter Site home page Giter Site logo

leaderboard-server's Introduction

Leaderboard Server

Build Status Coverage Status Dependency Status Dev Dependency Status

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.

Installation

git clone
npm install

Running the server

The server can be started on port 3000 by running:

npm start

API

/ping (GET)

Returns a "pong".

{
   "pong": "2018-09-04T23:59:53.199Z"
}

/games (GET)

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"}
      ]
   }
]

/games (POST)

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.

Example

curl -s 'http://localhost:3000/games' -H 'Content-Type: application/json' --data-binary '{ "players": [ { "score": 10 }, { "score": 20 }, { "score": 30 } ] }'

/top-scores (GET)

Returns the top scores that have been recorded.

[
   {"score":36,"name":"Incognito Cod"},
   {"score":20,"name":"Unnamed Rabbit"},
   {"score":10,"name":"Incognito Louse"}
]

License

This is released under the MIT license. See LICENSE.md for more information.

leaderboard-server's People

Contributors

onebytegone avatar pbredenberg avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.