Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

phineas-sdk

0.2.2 • Public • Published

Phineas Javascript SDK

Installation (browserify/webpack)

npm install --save phineas-sdk

or standalone build in dist/standalone.js which makes Phineas available globally.

Usage

const Phineas = require('phineas-sdk')
 
// appID and secret available from web UI 
const app = Phineas.inititalize({
    appID: <app_id>
  secret: <secret>
})
 
// 'Users' is the name of DynamoDB table
const UserTable = app.table('Users')
 
const username = 'alice'
const subscription = UserTable.subscribe('getUserInfo', username, function (err, data) {
  if(err) {
    throw err
  } 
 
  console.log(data)
})
 
 
subscription
  .on('INSERT', function (event) {
    console.log('new item added', event.newItem)
  })
  .on('MODIFY', function (e) {
    console.log('item modified', e.oldItem, e.newItem)
  })
  .on('REMOVE', function (e) {
    console.log('item deleted', e.oldItem)
  })
 
// unsubscribe
UserTable.unsubscribe('getUserInfo', username)
 

Instead of subscribing to a query, you can also make a one time call using the call callOnce() method.

const UserTable = app.table('Users')
 
UserTable.callOnce('getUserInfo', username, function (err, data) {
  if(err) {
    throw err
  } 
 
  console.log(data)
})
 

Keywords

Install

npm i phineas-sdk

DownloadsWeekly Downloads

0

Version

0.2.2

License

ISC

Last publish

Collaborators

  • avatar