Skip to content

qngapparat/soak-js

Repository files navigation

soak-js

On-the-fly hydration for FaaS. No more input & output size limits.

Install

npm i soak-js

Basic Usage

Before exporting, wrap your function in soak

AWS Lambda

const soak = require('soak-js');

const myFunction = (event, context, callback) => ({ foo: 'bar' })

exports.handler = soak(myFunction, {
  bucket: 'some-s3-bucket-for-stashing'
})

Google Cloud Functions

const soak = require('soak-js');

const myFunction = (req, res) => ({ foo: 'bar' }) // don't use res.json()

exports.myFunction = soak(myFunction, {
  bucket: 'some-gcloud-bucket-for-stashing'
})

Pass it unlimited inputs

// myBucket/largePayload.json
{ 
  "foo": "bar",
  "baz": 123
}
// invoke it with:
{ a: 1, _pointer: 'largePayload.json' }

// your function sees:
{ a: 1, foo: 'bar', 'baz': 123 }

Create unlimited outputs

return { almost: 'too', large: 'output' }
// => { almost: 'too', large: 'output' }

return { too: 'large', json: 'output' }
// => { _pointer: stashedOutputKey.json }

Platforms

Amazon AWS Lambda Google Cloud Functions using soak-js
Invocation payload 6 MB (sync) 10 MB unlimited
256 KB (async) unlimited
Response 6 MB (sync) 10 MB unlimited
256 KB (async) unlimited

Licence

MIT

Releases

No releases published

Packages

No packages published