Code Monkey home page Code Monkey logo

pushy-node-backend's Introduction

pushy-node-backend

A basic Node.js REST API built with Express for registering devices and sending push notifications with Pushy.

Pushy is the most reliable push notification gateway, perfect for real-time, mission-critical applications.

This API utilizes in-memory persistence to make things simple, but be aware that restarting the server will clear the registered devices list. Feel free to modify the persistence layer to utilize a real database, such as MongoDB.

Usage

Clone the repository locally and install its dependencies:

git clone https://github.com/pushy-me/pushy-node-backend.git

cd pushy-node-backend
npm install

Open config.js and insert your app's Secret API Key, available in the Dashboard:

pushy: {
    // Secret API Key
    secretApiKey: 'n00d4eea4f16btddd6d44fcfb72f2bbc20b8032175fdc979ada24a5d02b'
}

Start the server up:

npm start

API Endpoints

Note: All requests are GET requests to make it easy to execute them from a web browser for testing.

GET /

Returns a list of registered devices.

GET /register/:token

Register a device for notifications. Execute this request from your mobile app, replacing :token with the actual device token.

GET /push

Send a test notification to all registered devices, with the following payload:

{"message": "Hello World!"}

This request will throw an error if no devices have been registered yet, or if the Secret API Key is invalid:

{"error": "We could not find an app with the specified API key. Please contact us at [email protected]."}

Production Use

To actually use this in production, consider the following:

  1. Modify the push payload with data specific to your application

  2. Modify the persistence layer to utilize a real database, such as MongoDB

  3. Modify the /push endpoint to only send notifications to specific devices, based on app-specific criteria

License

Apache 2.0

pushy-node-backend's People

Contributors

pushy avatar

Watchers

Suhaib Abdulghani 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.