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

node-pushserver

v0.5.4

Published

Cross-platform Push Notifications. A project providing a generic API to push messages using Apple's APN and Google's GCM services.

Downloads

11

Readme

Push Server

Push Server is a cross-platform push server based on node-apn and node-gcm. Push Server currently supports iOS (APN) and android (GCM) platforms. It uses sqlite to store the push tokens. Note that this server is not meant to be used as a front facing server as there's no particular security implemented.

NPM

Getting started

1 - Database

node-pushserver uses sqlite to store the user / token associations.

2 - Install node-pushserver

  • From npm directly:
$ npm install node-pushserver -g
  • From git:
$ git clone git://github.com/Smile-SA/node-pushserver.git
$ cd node-pushserver
$ npm install -g

3 - Configuration

If you checked out this project from github, you can find a configuration file example named 'example.config.json'.

{
    "webPort": 8000,

    "sqlitePath": "./database.sqlite",

    "gcm": {
        "apiKey": "YOUR_API_KEY_HERE"
    },

    "apn": {
        "connection": {
            "gateway": "gateway.sandbox.push.apple.com",
            "cert": "/path/to/cert.pem",
            "key": "/path/to/key.pem"
        },
        "feedback": {
            "address": "feedback.sandbox.push.apple.com",
            "cert": "/path/to/cert.pem",
            "key": "/path/to/key.pem",
            "interval": 43200,
            "batchFeedback": true
        }
    }
}

Dynamic configuration

You can use the "process.env.MY_ENV_VAR" syntax in the config.json file. It will automatically be replaced by the value of the corresponding environment variable.

4 - Start server

$ pushserver -c /path/to/config.json

Override configuration

You can override your configuration with the "-o" or "--override" option by providing a key=value option. The key can be of the form key.subKey. If the value begins with process.env, it is evaluated. For example, if your sqlitePath comes from an environment variable:

$ pushserver -c /path/to/config.json -o sqlitePath=process.env.MY_ENV_VAR

If you want to set you GCM API key via the command line:

$ pushserver -c /path/to/config.json -o gcm.apiKey=YOUR_API_KEY

5 - Enjoy!

Usage

Web Interface

You can easily send push messages using the web interface available at http://domain:port/.

Web API

Send a push

http://domain:port/send (POST)
  • The content-type must be 'application/json'.
  • Format :
{
  "users": ["user1"],
  "android": {
    "collapseKey": "optional",
    "data": {
      "message": "Your message here"
    }
  },
  "ios": {
    "badge": 0,
    "alert": "Your message here",
    "sound": "soundName"
  }
}
  • "users" is optional, but must be an array if set. If not defined, the push message will be sent to every user (filtered by target).
  • You can send push messages to Android or iOS devices, or both, by using the "android" and "ios" fields with appropriate options. See GCM and APN documentation to find the available options.

Send push notifications

http://domain:port/sendBatch (POST)
  • The content-type must be 'application/json'.
  • Format :
{
  "notifications": [{
      "users": ["user1", "user2"],
      "android": {
        "collapseKey": "optional",
        "data": {
          "message": "Your message here"
        }
      },
      "ios": {
        "badge": 0,
        "alert": "Foo bar",
        "sound": "soundName"
      }
    },{
      "users": ["user4"],
      "android": {
        "collapseKey": "optional",
        "data": {
          "message": "Your other message here"
        }
      }
    }
  ]
}

Subscribe

http://domain:port/subscribe (POST)
  • The content-type must be 'application/json'.
  • Format:
{
  "user":"user1",
  "type":"android",
  "token":"CAFEBABE"
}
  • All field are required
  • "type" can be either "android" or "ios"
  • A user can be linked to several devices and a device can be linked to several users.

Unsubscribe

http://domain:port/unsubscribe (POST)
  • The content-type must be 'application/json'.
  • Format:
{
  "token":"CAFEBABE"
}

or

{
  "user":"user1"
}
  • You can unsubscribe either a particular device, or all the devices for one user

List Users

http://domain:port/users (GET)
  • Response format:
{
    "users": [
        "vilem"
    ]
}

List user's associations

http://domain:port/users/{user}/associations (GET)
  • Response format
{
    "associations": [
        {
            "user": "vilem",
            "type": "ios",
            "token": "06546b81450fc50fb3e26e513081f54642d7af3dedb57d9a4c557cc36a81dd252"
        }
    ]
}

Dependencies

Tags

node-pushserver tags.

History/Changelog

Take a look at the history.

License

MIT :

Copyright (C) 2012 Smile Mobile Team

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.