aws-lambda-helper
Advanced tools
Comparing version 2.13.0 to 2.13.1
@@ -363,2 +363,3 @@ 'use strict'; | ||
var assert = require('assert'); | ||
var resultBucket = new AWS.S3({params: {Bucket: process.env.AWS_S3_SEARCH_RESULT_BUCKET}}); | ||
@@ -370,12 +371,22 @@ /** | ||
function saveRecordToS3 (params, callback) { | ||
var filepath = params.userId + '/' + params.sessionId + '/' + params.id + '.json'; | ||
var env = AwsHelper.env; // remember to Initialise this! | ||
var s3params = { | ||
Bucket: process.env.AWS_S3_SEARCH_RESULT_BUCKET, | ||
Key: env + '/' + filepath, | ||
Body: JSON.stringify(params), | ||
ContentType: 'application/json', | ||
ACL: 'public-read' | ||
}; | ||
return resultBucket.upload(s3params, callback); | ||
var countdown = params.items.length; | ||
console.log(params.items); | ||
params.items.forEach(function (item) { | ||
var filepath = params.userId + '/' + params.id + '/' + item.id + '.json'; | ||
var env = AwsHelper.env; // remember to Initialise this! | ||
var s3params = { | ||
Bucket: process.env.AWS_S3_SEARCH_RESULT_BUCKET, | ||
Key: env + '/' + filepath, | ||
Body: JSON.stringify(params), | ||
ContentType: 'application/json', | ||
ACL: 'public-read' | ||
}; | ||
resultBucket.upload(s3params, function (err, data) { | ||
assert(!err); | ||
if (--countdown === 0) { | ||
return callback(err, data); | ||
} | ||
}); | ||
}); | ||
} | ||
@@ -392,3 +403,3 @@ AwsHelper.saveRecordToS3 = saveRecordToS3; // export for testing | ||
*/ | ||
var assert = require('assert'); | ||
AwsHelper.pushResultToClient = function (params, callback) { | ||
@@ -395,0 +406,0 @@ // push to WebSocket Server |
{ | ||
"name": "aws-lambda-helper", | ||
"version": "2.13.0", | ||
"version": "2.13.1", | ||
"description": "Collection of helper methods for lambda", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -66,9 +66,9 @@ // this test needs to run *FIRST* for some reason ... any help figuring out why much appreciated. | ||
var params = { | ||
id: CLIENT_ID, | ||
searchId: 12345, | ||
id: CLIENT_ID, // the session id from WebSocket Server | ||
searchId: 'ABC', | ||
userId: 'UniqueFingerprint', | ||
items: [ | ||
{hello: 'world', title: 'amazing holiday'}, | ||
{title: 'Sandy Beach with Fresh Coconuts'}, | ||
{title: 'Paradise Isle'} | ||
{id: 123, hello: 'world', title: 'amazing holiday'}, | ||
{id: 456, title: 'Sandy Beach with Fresh Coconuts'}, | ||
{id: 789, title: 'Paradise Isle'} | ||
] | ||
@@ -75,0 +75,0 @@ }; |
@@ -15,3 +15,4 @@ require('env2')('.env'); | ||
sessionId: 'test1234', | ||
userId: 'ClientFingerprint' | ||
userId: 'ClientFingerprint', | ||
items: [{id: 12345, title: 'my amazing hotel'}] | ||
}; | ||
@@ -18,0 +19,0 @@ AwsHelper.saveRecordToS3(params, function (err, data) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
193122
1550