A module that provides access to common services.
Run npm run generateReadme
to parse the code for JSDoc comment blocks and recreate this README.md file.
Run npm i @pillarwallet/common-services
Instantiate a badges service:
@param - (loggerPath - optional) Specify the file path to which log records are written
@param - (logToFile - optional - default false). Set true to enable logging to a file and file rotation
@param - (dbModels - optional) Pass the Badge and BadgeAward mongoose objects (need for the backend integration)
const { Badge, BadgeAward } = require('@pillarwallet/common-models').platform;
const { buildBadgeService } = require('@pillarwallet/common-services');
const BadgeService = buildBadgeService({
loggerPath: '',
logToFile: false,
dbModels: { Badge, BadgeAward },
});
Instantiate a notification service:
@param - (sqsConfiguration - required) Pass the SQS configuration object
@param - (dbModels - optional) Pass the Badge mongoose object (need for the backend integration)
const config = require('../../src/config');
const { Badge } = require('@pillarwallet/common-models').platform;
const { buildNotificationService } = require('@pillarwallet/common-services');
const notificationService = buildNotificationService({
sqsConfiguration: { region: 'us-east-1', queueUrl: 'https://sqs.us-east-1.amazonaws.com/testing/test.fifo', fifoQueue: true },
dbModels: { Badge },
});
- Constructor ⇒
This is the constructor of the BadgeService instance. It allows to set the Configuration keys:
- onUserRegistered ⇒
Method that awards user with a badge for the registration
- onWalletImported ⇒
Method that awards user with a badge for the imported wallet
- onConnectionEstablished ⇒
Method that awards user with a badge for the first connection
- onTransactionMade ⇒
Method that awards user with a badge for the first transaction made
- onTransactionReceived ⇒
Method that awards user with a badge for the first transaction received
- selfAward ⇒
Method to award yourself with a badge
- Constructor ⇒
This is the constructor of the NotificationService instance.
- retryMessage
Method to log error and call method sendMessage if corresponds
- sendMessage
Method to send a message to SQS
- createBadgesNotification
Method that creates a Badge notification and put the message in SQS
- onUserRegisteredBadgeNotification
Method that creates badge notification with type: wallet-created
- onWalletImportedBadgeNotification
Method that creates badge notification with type: wallet-imported
- onConnectionEstablishedBadgeNotification
Method that creates badge notification with type: first-connection-established
- onTransactionMadeBadgeNotification
Method that creates badge notification with type: first-transaction-made
- onTransactionReceivedBadgeNotification
Method that creates badge notification with type: first-transaction-received
This is the constructor of the BadgeService instance. It allows to set the Configuration keys:
Kind: global variable
Returns: Object
Param | Type | Description |
---|---|---|
[loggerPath] | String |
Specify the file path to which log records are written |
[logToFile] | Boolean |
Enables logging to a file and file rotation |
[dbModels] | Object |
Pass the Badge and BadgeAward mongoose objects |
Method that awards user with a badge for the registration
Kind: global variable
Returns: Promise
Param | Type | Description |
---|---|---|
[walletId] | String |
Wallet ID |
[userId] | String |
User ID |
Method that awards user with a badge for the imported wallet
Kind: global variable
Returns: Promise
Param | Type | Description |
---|---|---|
[walletId] | String |
Wallet ID |
[userId] | String |
User ID |
Method that awards user with a badge for the first connection
Kind: global variable
Returns: Promise
Param | Type | Description |
---|---|---|
[walletId] | String |
Wallet ID |
[userId] | String |
User ID |
Method that awards user with a badge for the first transaction made
Kind: global variable
Returns: Promise
Param | Type | Description |
---|---|---|
[walletId] | String |
Wallet ID |
[userId] | String |
User ID |
Method that awards user with a badge for the first transaction received
Kind: global variable
Returns: Promise
Param | Type | Description |
---|---|---|
[walletId] | String |
Wallet ID |
[userId] | String |
User ID |
Method to award yourself with a badge
Kind: global variable
Returns: Promise
Param | Type | Description |
---|---|---|
[badgeType] | String |
Badge name |
[walletId] | String |
Wallet ID |
[userId] | String |
User ID |
This is the constructor of the NotificationService instance.
Kind: global variable
Returns: Object
Param | Type | Description |
---|---|---|
[sqsConfiguration] | Object |
SQS configuration object |
[dbModels] | Object |
Pass the Badge mongoose object |
Method to log error and call method sendMessage if corresponds
Method to send a message to SQS
Kind: global variable
Param | Type | Description |
---|---|---|
[message] | Object |
The message object |
Method that creates a Badge notification and put the message in SQS
Kind: global variable
Param | Type | Description |
---|---|---|
[wallet] | Object |
The wallet object from the recipient user |
Method that creates badge notification with type: wallet-created
Kind: global variable
Param | Type | Description |
---|---|---|
[wallet] | Object |
The wallet object from the recipient user |
Method that creates badge notification with type: wallet-imported
Kind: global variable
Param | Type | Description |
---|---|---|
[wallet] | Object |
The wallet object from the recipient user |
Method that creates badge notification with type: first-connection-established
Kind: global variable
Param | Type | Description |
---|---|---|
[wallet] | Object |
The wallet object from the recipient user |
Method that creates badge notification with type: first-transaction-made
Kind: global variable
Param | Type | Description |
---|---|---|
[wallet] | Object |
The wallet object from the recipient user |
Method that creates badge notification with type: first-transaction-received
Kind: global variable
Param | Type | Description |
---|---|---|
[wallet] | Object |
The wallet object from the recipient user |