dynamo-db-local

A wrapper around Amazon's DynamoDB Local to start and stop it from Node.js.

Usage no npm install needed!

<script type="module">
  import dynamoDbLocal from 'https://cdn.skypack.dev/dynamo-db-local';
</script>

README

dynamo-db-local

A wrapper around Amazon's DynamoDB Local to start and stop it from Node.js.

dependencies version

This module wraps Amazon's DynamoDB Local. It just exposes one method called spawn() which does not much more than calling child_process.spawn() and returning it's result.

const dynamoDbLocalProcess = dynamoDbLocal.spawn();
// ...
dynamoDbLocalProcess.kill();

The spawn() function accecpts an optional options object which can have an optional path. If set, that path will be used to store the database file. If no path is specified the database will be kept in memory.

const path = 'somewhere/on/your/disk';
const dynamoDbLocalProcess = dynamoDbLocal.spawn({ path });
// ...
dynamoDbLocalProcess.kill();

Another property the options object could have is port. It specifies the port number that the process will run on. In absence of the port property, 8000 is used as the port number.

const port = 8001;
const dynamoDbLocalProcess = dynamoDbLocal.spawn({ port });
// ...
dynamoDbLocalProcess.kill();

Finally the options object could have a sharedDb property. If true, DynamoDB will use a single database file, instead of using separate files for each credential and region. The default of this option is false.

const dynamoDbLocalProcess = dynamoDbLocal.spawn({ sharedDb: true });
// ...
dynamoDbLocalProcess.kill();