/notification-service

A simple Notification service with Nodejs, MongoDB and Firebase-admin sdk

Primary LanguageJavaScript

Notification Service

This is a Notification service build with nodejs, it uses express, mongoose and firebase-admin sdk to send notifications. It let you

  1. subscribe a user to the notifications, subscribe a user to a certain topic.
  2. send notification to all the subscribed users, to a specific user or users, to a group of users with a common topic.
  3. send sms to all the subscribed users, to a specific user or users. (you have to integrate with an sms provider)
  4. refresh a certain user's firebase token.

Instructions

To Run the Project:

  • clone the repo or download it
  • cd into the directory of the project from the terminal
  • head to the Firebase console
  • create a new project from the firebase console and give it a name, or select an existing project.
  • go to your project's settings, then to service accounts, then generate new private key and download it.
  • rename serviceAccountKey.json.example to serviceAccountKey.json
  • copy the content of the private key file you just downloaded into serviceAccountKey.json
  • configure your mongo database in mongoose.js in my case i use a free cluster at MongoDB Atlas, and it's password will be in nodemon.json.example then rename it to nodemon.json
  • install all project dependencies with npm install
  • run the project with npm start and it will be listening at localhost:3000
  • test the project with npm test

To Run the Service with Docker:

  • make sure that docker and docker-compose are installed.
  • run sudo docker-compose up it will be listening at localhost:3000

The API contains 8 endpoints You can see a full Documentation for the API and examples from here

  1. /subscribe
    • /
    • /:topic
  2. /notifications
    • /
    • /notifications/toAll
    • /notifications/toGroup
  3. /sms
    • /
    • /toAll
  4. /refreshToken