npm.io
1.0.95 • Published 3 years ago

@hatsa/notifications

Licence
UNLICENSED
Version
1.0.95
Deps
8
Size
138 kB
Vulns
0
Weekly
0

Package - @hatsa/notifications

Usage

const sendPushNotification = genSendNotification({ firebase, logger, config, options });

sendPushNotification({ profileId, type, notification }).then().catch();

Where

genSendNotification
  • firebase - firebase-admin module
  • logger - Logger instance from @hatsa/log package
  • config - Config instance from @hatsa/config package
  • options - Optional argument see "Required options" section below.
sendPushNotification
  • profileId - User profile ID.
  • type - Notification type. Check notification-types.js for available types.
  • notification - Notification object. (Mostly the data of notification object from firestore)

Required options

Under the hood @hatsa/notifications package uses a CloudTask queue. That's why we need to pass some options in. We can pass it in as an options argument, or set in environment variables.

Options argument
{
  projectId: string; // Project ID
  queueId: string; // Queue ID
  functionUrl: string; // Handler function URL
  serviceAccount: string; // Service account email
  location: string; // Optional parameter, default value is "us-central1".
}
Environment variables
google_cloud_project                  #-> projectId
notifications_handler_queue           #-> queueId
notifications_handler_function_url    #-> functionUrl
notifications_handler_service_account #-> serviceAccount