Skip to content

Notificator is an API Rest backend that allows us to manage all our Firebase Cloud Messaging projects sending notifications to several devices per project in one app.

License

Notifications You must be signed in to change notification settings

kmorfo/Notificator

Repository files navigation

RLujanCreations Logo

This doc in Spanish

Description

Notificator is an API Rest backend that allows us to manage all our Firebase Cloud Messaging projects sending notifications to several devices per project in one app.

Includes the following features:

  • Swagger OpenAPI documentation
  • You can register one project per user/email
  • Authentication and authorization, using JWT and roles
  • Features separated by modules like Users, Auth, application, messages, etc.
    • Administration application users.
  • Password recovery via email with templates and temporary token
  • Email verification via email with templates and temporary token
  • Each application are multi user with roles
  • Each application can have multiple channels with a default channel
  • The mobile device registers in the app, the SHA of the application being validated as in Firebase and the application ID com.example.app through a Guard
  • Send Notification messages
    • Optional Image
    • Optional data in JSON format
  • Notification Scheduling

Notificator API

  1. Clone repositoty
  2. yarn install
  3. Clone .env.template file and rename it to .env
  4. Configure the environment variables according to our parameters
  5. Get up database container -d flag to open it decoupled from terminal
 docker compose -f docker-compose.dev.yaml -d up 
  1. Obtain a Firebase private key file Intro Firebase settings project go to service account, click in Generate new private key

  2. OpenAPI Documentation

http://localhost:3010/api/

Production notes

Run this command

docker compose -f docker-compose.prod.yaml -d up 

we also if we want to build only one of the services running the next command

docker compose -f docker-compose.prod.yaml build app

Alternatives

With the docker-compose.yaml file we can create the application in a docker container, launching the container with the database in turn.

docker compose -f docker-compose.dev.yaml up
yarn run start:dev

Get app in docker container with Dockerfile

docker container run  \
-dp 3010:3010 \
--name notificator \
kmorfo/notificator_app:latest

Standalone

  1. Create folder with the docker container name
  2. Copy docker-compose.standalone.yaml and .env.template files to the empty folder
  3. Rename .env.template file it to .env
  4. Configure the environment variables according to our parameters
  5. Run command
docker compose -f docker-compose.standalone.yaml up -d

If error when creating Image

One way to solve it is by eliminating the folder node_modules and yarn.lock file of the project. Now in the package.json file delete all ^ of the versions of the dependencies, this so that they install these exact versions.

If we had already raised the project

docker compose down --volumes
docker compose build
docker compose up

Links

Implement in-app notifications with NestJS, MySQL, and Firebase

TypeORM Docs

Nestjs File upload Docs

Other Examples

Sending a notification to a single device token

await firebase
  .messaging()
  .send({
    notification: {
      "title": "title",
      "body": "body"
    },
    token: token,
    android: { priority: 'normal' },
  }).then((response) => {
        console.log(response + ' messages were sent successfully');
      })
  .catch((error: any) => {
    console.error(error);
  });

Create Docker image and push to DockerHub

docker buildx build --platform linux/amd64,linux/arm64 \
-t kmorfo/notificator_app:1.1.1 \
--push .

License

MIT licensed.

About

Notificator is an API Rest backend that allows us to manage all our Firebase Cloud Messaging projects sending notifications to several devices per project in one app.

Resources

License

Stars

Watchers

Forks

Packages

No packages published