npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

leaderboards

v0.1.0

Published

A node.js module that creates a leaderboard server based on express.js and MongoDB. It accepts new scores and delivers leaderboards in JSON format via HTTP.

Downloads

3

Readme

leaderboards

A node.js module that creates a leaderboard server based on express.js and MongoDB. It accepts new scores and delivers leaderboards in JSON format via HTTP. The leaderboard server can be used with any device type (i.e. iOS, Android, HTML/Javascript), as long as the device can make HTTP requests to set and retrieve scores. The combination of a deviceID and a nickname is the unique key under which the scores are saved. So the application needs to create a unique deviceID for every device it runs on and get the users nickname.

Installation

npm install leaderboards

Usage

var Leaderboard = require("leaderboards");

var settings = {
	express_ipaddr : process.env.OPENSHIFT_INTERNAL_IP || process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1",
	express_port : process.env.OPENSHIFT_INTERNAL_PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080,
	dbName : "leaderboards",
	mongo_db_host : process.env.OPENSHIFT_MONGODB_DB_HOST || "127.0.0.1",
	mongo_db_port : process.env.OPENSHIFT_MONGODB_DB_PORT || 27018,
	pwd : "password",
	appIDs : {		
		"pipelinemanager" : "apple",		//appID : secret
		"messageontheblock" : "pie"
	}
};

var lb = new Leaderboard(settings);
lb.start();

This code creates and starts a leaderboard server that handles highscores for two applications (i.e. two leaderboards): "pipelinemanager" and "messageontheblock". The server expects a secret to authorize API requests for each application that wants to add a new score.

API

Add a new score

Make a simple HTTP GET request like this:

GET http://serverName.com/appID/deviceID/nickname?secret=yourSecret&score=userScore

Required parameters:

serverName .. the address under which the leaderboard server is running appID .. as defined in the leaderboard server settings secret .. as defined in the leaderboard server settings deviceID .. an ID for each device where the application is running, defined by yourself nickname .. nickname associated to the score score .. the new score to be added

Retrieve a leaderboard

Make a simple HTTP GET request like this:

GET http://serverName.com/appID

Required parameters:

serverName .. the address under which the leaderboard server is running appID .. as defined in the leaderboard server settings

Result example:

[
  {
    "_id": "53eca8c7c09d6a6c13d624ca",
    "appID": "pipelinemanager",
    "deviceID": "0815sdasdfg",
    "nickname": "Tom",
    "score": 20,
    "__v": 0,
    "created_at": "2014-08-14T12:17:11.671Z"
  },
  {
    "_id": "53eca8aec09d6a6c13d624c7",
    "appID": "pipelinemanager",
    "deviceID": "0815sdasdfg",
    "nickname": "Tom",
    "score": 129,
    "__v": 0,
    "created_at": "2014-08-14T12:16:46.767Z"
  },
  {
    "_id": "53eca8b4c09d6a6c13d624c8",
    "appID": "pipelinemanager",
    "deviceID": "0815sdasdfg",
    "nickname": "Julia",
    "score": 200,
    "__v": 0,
    "created_at": "2014-08-14T12:16:52.348Z"
  },
  {
    "_id": "53eca8c3c09d6a6c13d624c9",
    "appID": "pipelinemanager",
    "deviceID": "0815sdasdfg",
    "nickname": "Julia",
    "score": 2000,
    "__v": 0,
    "created_at": "2014-08-14T12:17:07.290Z"
  },
  {
    "_id": "53eca8d9c09d6a6c13d624cb",
    "appID": "pipelinemanager",
    "deviceID": "ffdgdfgdfg",
    "nickname": "Maria",
    "score": 1523,
    "__v": 0,
    "created_at": "2014-08-14T12:17:29.273Z"
  },
  {
    "_id": "53eca8fcc09d6a6c13d624cc",
    "appID": "pipelinemanager",
    "deviceID": "ffdgdfgdfg",
    "nickname": "Maria",
    "score": 2052,
    "__v": 0,
    "created_at": "2014-08-14T12:18:04.217Z"
  }
]