Askedio / pusher-lambda-promise

A basic Pusher.com trigger for AWS Lambda using promises.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pusher-lambda-promise

A basic pusher trigger for AWS Lambda using promises.

Related to pusher/pusher-http-node#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.triggerBatch(batch)
.then((results) => {
    console.log(results);
}).catch((error) => {
    console.error(error);
});

About

A basic Pusher.com trigger for AWS Lambda using promises.

License:MIT License


Languages

Language:JavaScript 100.0%