vesild

0.6.2 • Public • Published

VesilD

A very simple leaderboard service

  • RESTful (ish)
  • Redis Backed
  • Really Simple!

API

This is only sort of RESTful - don't @ me!

  • PATCH /leaderboard/:leaderboardKey/member/:memberKey

    Increments the score for a single member in a single leaderboard

    If the leaderboard does not exist then it is created

    If the member does not exist then it is created with score equal to points

    [
        {
            "path": "/points",
            "action": "increment",
            "value": (integer)
        }
     ]

    Returns a 200 response with body:

    {
         "member": (string),
         "leaderboard": (string),
         "points": (integer),
         "rank": (integer)
    }
  • PATCH /leaderboard/:leaderboardKey

    As above but allowing for the incrementing of multiple member points in a single leaderboard

    [
        {
             "path": "/member/:memberKey/points",
             "action": "increment",
             "value": (integer)
        },
        {
             "path": "/member/:memberKey/points",
             "action": "increment",
             "value": (integer)
        }
        ...
    ]
  • PATCH /member/:memberKey

    As above but allowing for the incrementing of multiple leaderboard points for a single member

    [
       {
           "path": "/leaderboard/:leaderboardKey/points",
           "action": "increment",
           "value": (integer)
       },
       {
           "path": "/leaderboard/:leaderboardKey/points",
           "action": "increment",
           "value": (integer)
       }
       ...
    ]
  • GET /leaderboard/:leaderboardKey?from=x&to=y

    Get a list of members in a leaderboard from position x to y

    First position is position x

    If not provided the x = 1, y = 10

    [
       {
          "member": (string),
          "leaderboard": (string),
          "points": (integer),
          "rank": (integer)
       },    
       {
          "member": (string),
          "leaderboard": (string),
          "points": (integer),
          "rank": (integer)
       },
       ...
    ]
  • GET /leaderboard/:leaderboardKey?includeMember=:id

    Includes the position of a member in the result set.

    To return just the position of this member pass from=0&to=0

    [
       {
          "member": (string),
          "leaderboard": (string),
          "points": (integer),
          "rank": (integer)
       },
       {
          "member": (string),
          "leaderboard": (string),
          "points": (integer),
          "rank": (integer)
       }
       ...
    ]
  • GET /member/:memberKey

    Gets a list of all leaderboards the member is part of

 [
   {
     "member": (string),
     "leaderboard": (string),
     "points": (integer),
     "rank": (integer)
   },    
   {
     "member": (string),
     "leaderboard": (string),
     "points": (integer),
     "rank": (integer)
   },
   ...
 ]
  • DELETE /leaderboard/:leaderboardKey/member/:memberKey

    Deletes a value by leaderboard and member keys

    Returns 204 on success

Readme

Keywords

none

Package Sidebar

Install

npm i vesild

Weekly Downloads

0

Version

0.6.2

License

MIT

Unpacked Size

27.5 kB

Total Files

12

Last publish

Collaborators

  • alecsammon