pusher-lambda-promise
v0.1.2
Published
A basic Pusher.com trigger for AWS Lambda using promises.
Downloads
78
Maintainers
Readme
pusher-lambda-promise
A basic pusher trigger for AWS Lambda using promises.
Related to https://github.com/pusher/pusher-http-node/issues/67
Installation
npm install --save pusher-lambda-promise
Usage
Require the module, and initialize Pusher with settings.
const Pusher = require('pusher-lambda-promise');
const pusher = new Pusher({
appId: process.env.PUSHER_APP_ID,
key: process.env.PUSHER_APP_KEY,
secret: process.env.PUSHER_APP_SECRET,
cluster: process.env.PUSHER_APP_CLUSTER
});
Trigger single event
pusher.trigger('update', 'private-channel', {
foo: 'foo',
bar: 'bar'
}).then((results) => {
console.log(results);
}).catch((error) => {
console.error(error);
});
Trigger batch events
const batch = [
{
foo: 'foo',
bar: 'bar'
},
{
foo: 'foo',
bar: 'bar'
}
];
pusher.trigger(batch)
.then((results) => {
console.log(results);
}).catch((error) => {
console.error(error);
});