This is a Notification service build with nodejs, it uses express, mongoose and firebase-admin sdk to send notifications. It let you
- subscribe a user to the notifications, subscribe a user to a certain topic.
- send notification to all the subscribed users, to a specific user or users, to a group of users with a common topic.
- send sms to all the subscribed users, to a specific user or users. (you have to integrate with an sms provider)
- refresh a certain user's firebase token.
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
toserviceAccountKey.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 innodemon.json.example
then rename it tonodemon.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
- /subscribe
- /
- /:topic
- /notifications
- /
- /notifications/toAll
- /notifications/toGroup
- /sms
- /
- /toAll
- /refreshToken