- Create the project from the following template:
$ sls create --template-url https://github.com/danteinc/js-cloud-native-cookbook/tree/master/ch8/idempotence-inverse-oplock --path cncb-idempotence-inverse-oplock
- Navigate to the cncb-idempotence-inverse-oplock directory with cd cncb-idempotence-inverse-oplock.
- Review the file named serverless.yml.
- Review the file named handler.js with the following content:
module.exports.listener = (event, context, cb) => { _(event.Records) .map(recordToUow) .filter(forThingSaved) .flatMap(save) .collect().toCallback(cb);};const save = uow => { const params = { TableName: process.env.TABLE_NAME, Item: { ...uow.event.thing, oplock: uow.event.timestamp, }, ConditionExpression: 'attribute_not_exists(#oplock) ...