1.1.0 • Published 7 years ago

bragg-dynamodb v1.1.0

Weekly downloads
86
License
MIT
Repository
github
Last release
7 years ago

bragg-dynamodb Build Status

DynamoDB middleware for bragg.

This little piece of middleware makes it possible to handle DynamoDB events as if they where normal requests.

Install

$ npm install --save bragg-dynamodb

Usage

const app = require('bragg')();
const router = require('bragg-router')();
const dynamodb = require('bragg-dynamodb');

// Listen for events triggered by the `MyTable` and `MyTableDev` table
router.post('dynamodb:MyTable', ctx => {
	console.log(ctx.request.params.table);
	// `MyTable`

	ctx.body = ctx.request.body;
});

app.use(dynamodb({MyTableDev: 'MyTable'}));
app.use(router.routes());

exports.handler = app.listen();

The dynamodb: prefix is attached by this module and is followed by the name of the table that triggered the event. The changes of the table are provided in the body property of the request object.

API

dynamodb(options)

options

Type: object

Map a table name to another name.

License

MIT © Sam Verschueren