Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
parse-to-anh
Advanced tools
Node.js module and tool to migrate android and ios users from parse to Azure Notification Hubs.
The script updates the _Installation
collection with a new property anhRegistrationId
that can later be used to send puah notifications for the user.
Sending a notification to a user is done by sending a notification to a tag of the user's anhRegistrationId
. Example below.
In addition, you can provide a handler function that will get the RegistrationId and run your own logic. For example, if you wish to save this registrationId in another collection, or provision it against an addition API.
npm install parse-to-anh -g
Create a configuration file: config.json
:
{
"mongoUrl": "yourMongoUrl",
"hubName": "yourAzureHubName",
"hubConnection": "yourAzureHubConnectionString",
"tags": [],
"reRegister": true,
"batchSize": 100,
"limit": 0
}
mongoUrl
- The Url for your mongo db that was migrated from parse
hubName
- The Azure Notification Hub name
hubConnection
- The Azure Notification Hub connection string
tags
- Default list of tags that will be added to the user
reRegister
- [Optional, default false
] ReRegister users that were already registered. This can be used if for some reason you run the script again on a db that was only partially processed.
batchSize
- [Optional] The size of the batch used by mongo client
limit
- [Optional] Use that to limit the number of items to process. Can be used to test with a small amount of items, before processing the whole collection.
registrationHandler
- [Optional]- a callback function that gets an _Installation
document containing the new anhRegistrationId
field. This handler will be called for each successfull user registration. This is the place for you to add your own custom code to handle the registrationId.
run:
parse-to-anh config.json
Grab a coffee and relax...
Check the sample file for a reference
var migrator = require('parse-to-anh');
var config = {
"mongoUrl": "yourMongoUrl",
"hubName": "yourAzureHubName",
"hubConnection": "yourAzureHubConnectionString",
"tags": [],
"reRegister": true,
"batchSize": 100,
"limit": 0,
"registrationHandler": myHandler
};
function myHandler(installation, cb) {
// TODO: custom code to use installation.anhRegistrationId
// and the rest of the properties of the installation document
return cb();
}
console.log('starting registering to Azure Notification Hub...');
migrator.start(config, function (err) {
if (err) return console.error('error occurred:', err);
console.log('migration completed successfully');
});
Use the anhRegistrationId
to send a notification to the user.
The below example assumes an ios
user, using apns
to send the notification:
var azure = require('azure');
var hubService = azure.createNotificationHubService(hubName, hubConn);
var payload = {
alert: 'Hello from Azure Notification Hubs!'
};
var tags = [anhRegistrationId];
hubService.apns.send(tags, payload, function (err) {
if (err) return console.error('error sending notification', err);
console.log('Success: notification sent');
});
FAQs
migrates parse users to Azure Notification Hubs
The npm package parse-to-anh receives a total of 1 weekly downloads. As such, parse-to-anh popularity was classified as not popular.
We found that parse-to-anh demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.