Skip to content

Instantly share code, notes, and snippets.

@Charuru
Last active January 1, 2016 15:59
Show Gist options
  • Save Charuru/8167613 to your computer and use it in GitHub Desktop.
Save Charuru/8167613 to your computer and use it in GitHub Desktop.
Install instructions for Raghav

Notifications Demo

Install

Make sure you have node.js and NPM installed.

Set your terminal to this directory.

// use npm to install all the required modules
npm install

// run the server
node server.js

API Endpoints

Send a PM to a user

POST /api/pm

Pass in the originating user, the to users, and the messsage body

{
  user: $.cookie('user_id'), // string
  toUsers: users, // array of user_ids
  body: $('textarea').val(), // string
}

Get all of a user's notifications

GET /api/notification/:user_id

Pass in the user_id id

Get a user's unread notifications

GET /api/notification/:user_id/unread

Pass in the user_id id

Get a user's read notifications

GET /api/notification/:user_id/read

Pass in the user_id id

Mark a notification as read

POST /api/notification/read/:notificationID

Pass in the notification id

Mark a notification as read

POST /api/notification/read/:notificationID

Pass in the notification id

Create a notification for specific users

POST /api/notification

Send an object with the users and the message in this format:

{
  toUsers: ['user1', 'user2'], // array of user_ids
  msg: {
    type: "pm", // type of notification, would be useful for when you have need for multiple types of notifications in the future.
    body: "Good Morning", // String, text of the message
    title: "You got a personal message from " + content.user // String, text of the message
  }
}

This end point is not used in this demo. It's for future integration.

Integration Advice:

Load the css and javascript that's in the layout.jade file. For the script to work there needs to be some HTML endpoints. Check the HTML in the index.jade file and copy everything inside #loginMenu

If you're confused by the jade templating language and need help converting to HTML use this: http://html2jade.com/

Requirements

-> Notification system administrator panel -> Publish system using node.js -> Rest api to publish messges (format -> message , user_id) via php -> Frontend UI ( where notification appear real time and also facebook like notification drop down ) -> Create sample of 10 users for demonstration purpose -> Real time notification should appear also as dialog (right end corner) -> Provision for read and unread notification -> Documentation of how to install -> User interface code snapshot which we will use to integrate to your user interface for real time notification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment