This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var saveInventory = function(req, res) { | |
| var body = req.body | |
| console.log(body); | |
| } | |
| server.post('/inventory/:id', saveInventory); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| function InventoryMock() { | |
| this.inventory = []; | |
| } | |
| exports.InventoryMock = new InventoryMock(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 })); |