Skip to content

Instantly share code, notes, and snippets.

View richardhyatt's full-sized avatar

Richard Hyatt richardhyatt

View GitHub Profile
@richardhyatt
richardhyatt / index.js
Created October 20, 2017 20:27
scheduled handler using vandium
'use strict';
const vandium = require( 'vandium' );
// environment variables are set at this point since vanidum
// will load them from Parameter Store
exports.handler = vandium.scheduled( (event, context ) => {
console.log( 'ABC = ', proceass.env.ABC );
@richardhyatt
richardhyatt / index.js
Last active October 20, 2017 18:51
trivial handler using vandium
'use strict';
require( 'vandium' );
exports.handler = function( event, context, callback ) {
console.log( 'ABC = ', proceass.env.ABC );
callback( null, 'ok' );
};
Handler: index.js
Runtime: nodejs6.10
CodeUri: 's3://my-code-bucket/my-function.zip'
Description: Creates thumbnails of uploaded images
MemorySize: 1024
Timeout: 15
Policies:
- AWSLambdaExecute # Managed Policy
- Version: '2012-10-17' # Policy Document
Statement:
@richardhyatt
richardhyatt / index.js
Last active June 11, 2019 18:09
Unit Testing AWS Lambda Functions in Node.js #3
'use strict';
var expect = require( 'chai' ).expect;
var LambdaTester = require( 'lambda-tester' );
var myLambda = require( '../index' );
describe( 'myLambda', function() {
@richardhyatt
richardhyatt / index.js
Last active May 5, 2017 19:01
Unit Testing AWS Lambda Functions in Node.js #2
'use strict';
var expect = require( 'chai' ).expect;
var myLambda = require( '../index' );
describe( 'myLambda', function() {
[
"Richard",
@richardhyatt
richardhyatt / index.js
Created May 5, 2017 18:52
Unit Testing AWS Lambda Functions in Node.js #1
‘use strict’;
exports.handler = function( event, context, callback ) {
if( (event.name === ‘Richard’) || (event.name === ‘rhyatt’ ) ) {
return callback( null, { valid: true } );
}
callback( new Error( ‘unknown name’ ) );
@richardhyatt
richardhyatt / index.js
Created May 4, 2017 21:56
Basic Lambda Function
'use strict';
exports.handler = function( event, context, callback ) {
// Do something here
callback( null, 'success!' );
});
@richardhyatt
richardhyatt / index.js
Created May 4, 2017 21:44
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( {
@richardhyatt
richardhyatt / index.js
Last active May 4, 2017 19:17
Simple Lambda Handler using Vandium with Validation
'use strict';
const vandium = require( 'vandium' );
// our datastore
const db = require( './lib/db' );
exports.handler = vandium.api()
.POST( {
@richardhyatt
richardhyatt / index.js
Last active May 4, 2017 19:21
Simple POST handler using Vandium
'use strict';
const vandium = require( 'vandium' );
// our datastore
const db = require( './lib/db' );
exports.handler = vandium.api()
.POST( (event) => {