mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-26 08:54:43 +00:00
AWS plugin: Add support for a compressed payload
AWS imposes a limit of 16MB in my testing for the payload of a lambda. Compressing it enables us to pass x2-3 more data, thanks to the inefficiencies of JSON
This commit is contained in:
@@ -16,15 +16,29 @@ exports.handler = function(event,context,callback) {
|
||||
$tw.packageInfo = lambdaPackageInfo;
|
||||
// Load any tiddlers from the package
|
||||
$tw.preloadTiddlerArray(lambdaTiddlers);
|
||||
// Load any tiddlers from the event
|
||||
if(event.tiddlers) {
|
||||
$tw.preloadTiddlerArray(event.tiddlers);
|
||||
// Decompress the event data if required
|
||||
if(typeof event.compressed === "string") {
|
||||
require("zlib").gunzip(Buffer.from(event.compressed,"base64"),function(err,buff) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
boot(JSON.parse(buff.toString()));
|
||||
});
|
||||
} else {
|
||||
boot(event);
|
||||
}
|
||||
|
||||
function boot(event) {
|
||||
// Load any tiddlers from the event
|
||||
if(event.tiddlers) {
|
||||
$tw.preloadTiddlerArray(event.tiddlers);
|
||||
}
|
||||
// Load the commands from the event
|
||||
$tw.boot.argv = (event.commands || []).slice(0);
|
||||
// Boot the TW5 app
|
||||
_boot($tw);
|
||||
$tw.boot.boot(function() {
|
||||
callback(null,$tw["lambda-result"]);
|
||||
});
|
||||
}
|
||||
// Load the commands from the event
|
||||
$tw.boot.argv = (event.commands || []).slice(0);
|
||||
// Boot the TW5 app
|
||||
_boot($tw);
|
||||
$tw.boot.boot(function() {
|
||||
callback(null,$tw["lambda-result"]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user