Skip to content

Instantly share code, notes, and snippets.

View ryanbrown-iress's full-sized avatar

Ryan Brown ryanbrown-iress

  • Iress
  • Melbourne
View GitHub Profile
@ryanbrown-iress
ryanbrown-iress / aws_item_store.js
Last active April 1, 2019 23:31
Better lambda example with separation of conserns
View aws_item_store.js
const AWS = require('aws-sdk');
const dynamoDb = new AWS.DynamoDB.DocumentClient();
exports.insert = (item, successCallback, errorCallback) => {
const params = {
TableName: process.env.DYNAMODB_TABLE,
Item: item
};
dynamoDb.put(params, (error) => {
@ryanbrown-iress
ryanbrown-iress / example_lambda.js
Created April 1, 2019 23:01
Example of an all in one Lambda using NodeJS
View example_lambda.js
const uuid = require("uuid");
const AWS = require("aws-sdk");
const dynamoDb = new AWS.DynamoDB.DocumentClient();
exports.handler = (event, context, callback) => {
const data = JSON.parse(event.body);
const errors = [];
if (typeof data.title !== "string") {
errors.push("Invalid title");