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
Last active May 4, 2017 18:38
Sample AWS Lambda handler for API Gatway
'use strict';
// our datastore
const db = require( './lib/db' );
exports.handler = function( event, context, callback ) {
// prevent Lambda from being used in requests outside POST
if( event.httpMethod !== 'POST' ) {
{
"userId": "b08f86af-35da-48f2-8fab-cef3904660bd"
}
{
"typ": "JWT",
"alg": "HS256"
}
@richardhyatt
richardhyatt / index.js
Created May 9, 2016 01:00
Vandium JWT without token service
'use strict';
const vandium = require( 'vandium' );
const bluebird = require( 'bluebird' );
// our nosql datastore - promisified
const db = bluebird.promisifyAll( require( './lib/db' ) );
// message service - promisified
@richardhyatt
richardhyatt / configure-jwt.js
Created May 9, 2016 00:45
Configuring JWT validation using Vandium
vandium.jwt.configure( {
algorithm: 'HS256',
secret: 'secret'
});
@richardhyatt
richardhyatt / index.js
Created May 9, 2016 00:41
vandium JWT
'use strict';
const vandium = require( 'vandium' );
const bluebird = require( 'bluebird' );
// our token validation service - promisified
const tokenValidator = bluebird.promisifyAll( require( './lib/token-validator' ) );
// our nosql datastore - promisified
@richardhyatt
richardhyatt / index.js
Created April 17, 2016 11:50
using vandium node - promise further refined
'use strict';
const vandium = require( 'vandium' );
const bluebird = require( 'bluebird' );
// our token validation service - promisified
const tokenValidator = bluebird.promisifyAll( require( './lib/token-validator' ) );
// our nosql datastore - promisified
@richardhyatt
richardhyatt / index.js
Created April 16, 2016 14:41
lambda-node-redis-load
'use strict';
const redis = require( 'redis' );
exports.handler = function( event, context, callback ) {
callback( null, 'ok' );
};
@richardhyatt
richardhyatt / index.js
Created April 16, 2016 14:15
min-lambda-nodejs
'use strict';
exports.handler = function( event, context, callback ) {
callback( null, 'ok' );
};
@richardhyatt
richardhyatt / index.js
Created April 16, 2016 13:49
redis-promisification
const redis = require( 'redis' );
const bluebird = require( 'bluebird' );
bluebird.promisifyAll(redis.RedisClient.prototype);
bluebird.promisifyAll(redis.Multi.prototype);