Skip to content

Instantly share code, notes, and snippets.

@richardhyatt
Created May 4, 2017 21:44
Show Gist options
  • Select an option

  • Save richardhyatt/ef1503eb87ce369c8641fbeee635af2e to your computer and use it in GitHub Desktop.

Select an option

Save richardhyatt/ef1503eb87ce369c8641fbeee635af2e to your computer and use it in GitHub Desktop.
Simple Lambda handler using Vandium with finally() clause
'use strict';
const vandium = require( 'vandium' );
// our datastore
const db = require( './lib/db' );
exports.handler = vandium.api()
.POST( {
body: {
userName: vandium.types.string().min(4).max(100).required()
}
},
(event) => {
let userName = event.body.userName;
return db.addUser( userName );
})
.finally( () => {
return db.closeCache();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment