npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dynamodb-touch

v0.1.0

Published

[![Build Status](https://travis-ci.org/mapbox/dynamodb-touch.svg?branch=master)](https://travis-ci.org/mapbox/dynamodb-touch)

Downloads

8

Readme

dynamodb-touch

Build Status

Simulated DynamoDB Stream events based on the contents of a DynamoDB table.

What it does

Performs either a GetItem, Query, or Scan operation on a DynamoDB table, then passes each resulting record into a Kinesis stream in a wrapper identical to what would be provided by a DynamoDB stream INSERT event.

How to use it

You must provide your own configured Dyno and Kinesis clients. The Kinesis client must be pre-configured to provide the stream name with each request.

var touch = require('dynamodb-touch');
var AWS = require('aws-sdk');
var Dyno = require('dyno');

var clients = {
  dyno: Dyno({
    table: 'my-dynamodb-table',
    region: 'us-east-1'
  }),
  kinesis: new AWS.Kinesis({
    region: 'us-east-1',
    params: { StreamName: 'my-kinesis-stream' }
  })
};

// send one event for a dynamodb record with the provided key
touch.one({ id: 'some-record' }, clients, function(err) {
  if (err) throw err;
});

// query dynmodb, sending events for each result
touch.some({
  KeyConditions: {
    id: {
      ComparisonOperator: 'EQ',
      AttributeValueList: ['some-record']
    }
  }
}, clients, function(err) {
  if (err) throw err;
});

// scan every record in dynamodb, sending events for each result
touch.every(clients, function(err) {
  if (err) throw err;
});

// send one event for a feature that has already been fetched
var item = { id: 'record-id', data: 'record-data' };
touch.thisOne(item, clients, function(err) {
  if (err) throw err;
});

What events in Kinesis will look like

A Kinesis event will contain a Data property. For dynamodb-touch events, this will be a base64-encoded JSON string which mimics a DynamoDB Stream event.

kinesis.getRecords({ ShardIterator: 'xyz' }, function(err, data) {
  var record = data.Records[0];
  var dynamodbEvent = JSON.parse((new Buffer(record.Data, 'base64')).toString());
  console.log(JSON.stringify(dynamodbEvent, null, 2));
});

... will console.log:

{
  "eventId": "0",
  "eventVersion": "1.0",
  "awsRegion": "us-east-1",
  "eventSourceARN": "arn:aws:dynamodb:us-east-1:000000000000:table/my-dynamodb-table/dynamodb-touch",
  "eventSource": "dynamodb-touch",
  "eventName": "INSERT",
  "dynamodb": {
    "Keys": {
      "id": { "S": "my-record" }
    },
    "NewImage": {
      "id": { "S": "my-record" },
      "data": { "B": "aGVsbG8geW91" }
    },
    "StreamViewType": "NEW_IMAGE",
    "SequenceNumber": "0",
    "SizeBytes": 52
  }
}