Example on how to run locally an AWS Lambda via API Gateway using localstack.
Based on...
| --log_gc (Log heap samples on garbage collection for the hp2ps tool.) | |
| type: bool default: false | |
| --expose_gc (expose gc extension) | |
| type: bool default: false | |
| --max_new_space_size (max size of the new generation (in kBytes)) | |
| type: int default: 0 | |
| --max_old_space_size (max size of the old generation (in Mbytes)) | |
| type: int default: 0 | |
| --max_executable_size (max size of executable memory (in Mbytes)) | |
| type: int default: 0 |
| let params = { | |
| TableName: 'xxx', | |
| Limit: 50 // Configure based on needs | |
| }; | |
| let aItems = []; | |
| const recursiveScan = (params) => { | |
| return client.scan(params).promise().then((data) => { | |
| // Simple Changes to input, optional | |
| let newItems = data.Items.map((item) => { | |
| return item; |
| // under Google Chrome 36 | |
| Object.prototype.toString.call([]) | |
| // "[object Array]" | |
| Object.prototype.toString.call(function(){}) | |
| // "[object Function]" | |
| Object.prototype.toString.call({}) | |
| // "[object Object]" | |
| Object.prototype.toString.call(null) | |
| // "[object Null]" |
| const waitFor = (ms) => new Promise(r => setTimeout(r, ms)) | |
| const asyncForEach = async (array, callback) => { | |
| for (let index = 0; index < array.length; index++) { | |
| await callback(array[index], index, array) | |
| } | |
| } | |
| const start = async () => { | |
| await asyncForEach([1, 2, 3], async (num) => { | |
| await waitFor(50) |
Example on how to run locally an AWS Lambda via API Gateway using localstack.
Based on...