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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ddb-local

v0.2.0

Published

A thin wrapper around AWS's DynamoDB-Local to make using it in unit tests a bit simpler.

Readme

ddb-local

A thin wrapper around AWS's DynamoDBLocal to make using it in unit tests a bit simpler.

NPM Version Build

Install

npm install --save ddb-local

Usage

Example usage with Mocha

Set an env var for your DynamoDB endpoint in your package.json test script

  "scripts": {
    "test": "NODE_ENV=test AWS_DDB_ENDPOINT=http://localhost:3547 mocha --timeout 30000"
  },

Start up DdbLocal before running your application tests, and shut it down after.


var DdbLocal = require('ddb-local');

describe('ddb', function () {
    var ddblocal = new DdbLocal();
    
    before(function (done) {
        ddblocal.start(done);
    }
    
    describe('application tests...');
    
    after(function (done) {
        ddblocal.stop(done);
    });
});

Then wihin your application code, any time you create a new DynamoDB client, set the endpoint if the env var is set.

    var dynamoParams = {
        apiVersion: '2012-08-10',
        endpoint: process.env.AWS_DDB_ENDPOINT
    };
    var dynamo = new AWS.DynamoDB(dynamoParams);

Now when you run $ npm test your application will be using DynamoDBLocal instead of the real DynamoDB. Keep in mind that if your application code assumes your DynamoDB tables already exist, you'll have to create them in your test setup.

Options

ddb-local supports a few configuration options via both env var and constructor params new DdbLocal(options)

  • Download path for the DynamoDBLocal jar file. Set with options.jarDir or by setting DEFAULT_DOWNLOAD_PATH env var
  • Port for DynamoDBLocal to listen on. Set with options.port or DDB_PORT
  • Endpoint for DynamoDBLocal to use. Overrides the Port option. Set with AWS_DDB_ENDPOINT
  • Whether to store data in memory (default) or files. Set options.inMemory=false or DDB_LOCAL_IN_MEMORY=false to use files.

Self-contained Example (no test framework)

var AWS = require('aws-sdk');
var DdbLocal = require('ddb-local');
var assert = require('assert');

var localdb = new DdbLocal();
localdb.start(function (err) {
    assert.ifError(err);
    // Now use DynamoDB normally, just set the endpoint to localdb.endpoint
    var AWS = require('aws-sdk');
    
    var dynamoParams = {
        apiVersion: '2012-08-10',
        endpoint: localdb.endpoint
    };
    var client = new AWS.DynamoDB(dynamoParams);
    var tableParams = {
        TableName: 'test',
		AttributeDefinitions: [
			{
				AttributeName: 'id',
				AttributeType: 'S'
			}
		],
		KeySchema: [
			{
				AttributeName: 'id',
				KeyType: 'HASH'
			}
		],
		ProvisionedThroughput: {
			ReadCapacityUnits: 5,
			WriteCapacityUnits: 5
		}
    };
    client.createTable(tableParams, function (err, result) {
        assert.ifError(err);
        assert.equal(result.TableDescription.TableName, tableParams.TableName);
        done();
    });
    
    // Stop LocalDB when you're done
    localdb.stop();
});