README
avatarbox.sdk
nodejs sdk for avatarbox.io
Description
avatarbox.sdk is a specialized library designed to facilitate the development of application components such as avatarbox.publisher, avatarbox.worker, avatarbox.app and avatarbox.api. Unlike a general-purpose library, avatarbox.sdk is tailored to back-end resources situated within the AvatarBox Virtual Private Cloud (VPC) hosted on Amazon Web Services (AWS).
Checklist
- Pusher Channel
- DynamoDB table:
Gravatars
- partition key:
email
- enable DynamoDB stream
- enable TTL using the
expires_on
field - define trigger: avbx-trigger-gravatar-deleted
- Global Secondary Index
- name:
index-id-email
- partition key:
id (Number)
- sort key:
email (String)
- name:
- partition key:
- DynamoDB table:
TwitterProfiles
- partition key:
id
- enable TTL using the
expires_on
field
- partition key:
- KMS Symmetric Key
- SQS Queue
SQS Queue Setup:
Setting | Description |
---|---|
Lambda Triggers | avbx-worker a. |
Name | avbx-worker-queue |
Type | Standard |
a. Use avatarbox.worker to define this Lambda function.
Installation
# clone repo
$ git clone https://github.com/mrtillman/avatarbox.sdk.git
# install dependencies
$ cd avatarbox.sdk && npm install
Next, find demo.env, rename it to .env
and modify:
KMS_KEY_ID={YOUR-KMS-KEY-ID}
REGION=us-east-1
QUEUE_URL={YOUR-SQS-QUEUE-URL}
PUSHER_APP_ID=0000000
PUSHER_SECRET=xxxxxxxxxxxxxxxxxxx
PUSHER_KEY=11111112222222333333
PUSHER_CLUSTER=xx1
Tests
# unit tests
$ npm test
# test coverage
$ npm run test:cov
Usage
avatarbox.sdk defines a Gravatar client and a Twitter client. Both implement the AvbxClient interface.
import {
AvbxGravatarClient,
AvbxTwitterClient
} from 'avatarbox.sdk';
const gravatarClient = new AvbxGravatarClient();
const twitterClient = new AvbxTwitterClient();