Skip to content

Instantly share code, notes, and snippets.

View lohmann's full-sized avatar

Marcio Lohmann lohmann

View GitHub Profile
@lohmann
lohmann / lambda_cloudsearch.js
Created January 26, 2016 12:50 — forked from fzakaria/lambda_cloudsearch.js
Send CloudTrail events to CloudSearch with AWS Lambda
console.log('Loading event');
var CLOUDSEARCH_ENDPOINT = < INSERT HERE >
var async = require('async');
var jpath = require('json-path')
var zlib = require('zlib');
var aws = require('aws-sdk');
var s3 = new aws.S3({
apiVersion: '2006-03-01'
});
@lohmann
lohmann / indexAccountsToCloudsearch.js
Created January 26, 2016 12:50 — forked from ryanfitz/indexAccountsToCloudsearch.js
index dynamodb data to cloudsearch using AWS Lambda
var AWS = require('aws-sdk');
exports.handler = function(event, context) {
var cloudsearchdomain = new AWS.CloudSearchDomain({endpoint: 'doc-dev-cinch-accounts-ltmqj5gt5mjb5hg5eyqaf2v5hu.us-east-1.cloudsearch.amazonaws.com'});
var documents = event.Records.map(function(record) {
var data = {id : record.dynamodb.Keys.id.S};
if (record.eventName === 'REMOVE') {
data.type = 'delete'
@lohmann
lohmann / saveInfo
Last active August 28, 2015 12:22 — forked from jcdalton2201/saveInfo
save info
var saveInventory = function(req, res) {
var body = req.body
console.log(body);
}
server.post('/inventory/:id', saveInventory);
@lohmann
lohmann / InventoryMock
Last active August 28, 2015 01:44 — forked from jcdalton2201/InventoryMock
MockData
'use strict';
function InventoryMock() {
this.inventory = [];
}
exports.InventoryMock = new InventoryMock();
@lohmann
lohmann / inventory.js
Last active August 28, 2015 01:43 — forked from jcdalton2201/inventory.js
inventoryDemo
'use strict';
var q = require('q');
var mock = require('./mock/inventoryMock.js');
function findInventory (id) {
var promise = q.defer();
if(id){
var filter = mock.InventoryMock.inventory.filter(
function(item){
return item.guid === id;
@lohmann
lohmann / index.js
Last active August 28, 2015 01:43 — forked from jcdalton2201/index.js
NodeServer
#!/bin/env node
var restify = require('restify');
var port = process.env.NODE_PORT || 8081;
var ip = '127.0.0.1';
//create servers
var server = restify.createServer();
//create the handlers.
server.use(restify.CORS());
server.use(restify.bodyParser({ mapParams: false }));