socketsupply / fake-api-gateway-lambda Goto Github PK
View Code? Open in Web Editor NEWThis is a testing utility for testing your lambda functions.
License: MIT License
This is a testing utility for testing your lambda functions.
License: MIT License
Currently, if a lambda is written in ESM we get the [ERR_REQUIRE_ESM]
error in the JavaScript worker because https://github.com/socketsupply/fake-api-gateway-lambda/blob/master/workers/js-worker-txt.js#L184 does not handle such case.
The enable cors functionality in this module is how I wish api-gateway worked -- it sets the header on the response, which is sent to the client, even if the lambda doesn't set it. however, this isn't actually how aws lambda works. When I was trying to make cors work with lambda it only worked when I explicitly set the cors headers in the lambda.
This requires checking in 3 languages, something like
setInterval(() => {
const ht = process.memoryUsage().heapTotal
const mb = Math.round(ht / 1024 / 1024 * 100) / 100)
if (ht >= MAX_MEM) process.exit(EXIT_CODE)
}, 512)
setTimeout(() => {
process.exit(EXIT_CODE)
}, MAX_RUNTIME)
When I try to call into a go lambda that has a compile or runtime error I get
dial tcp: connection refused
Looks like we need to get more error output bubbled up.
if you deploy code to lambda that has a syntax error, iirc it becomes a runtime Internal Server Error to the client request.
but deploying a lambda with this code will cause the worker process to crash.
curiously, it crashes on the first request.
reading the code, I see that each worker loads all lambdas. That means that one broken lambda breaks everything.
I've been trying this with rootless docker. (so you don't have to run sudo docker on every command...)
it has weirdly different behavior. It fails the tests with a network error - ECONREFUSED. Weirdly, it gets part way through and then fails.
Also, rootless docker is much slower. With root, the tests pass in 15 seconds, without root, they fail after 45 seconds, on the 3rd test of 5!
https://github.com/yogeshlonkar/aws-lambda-go-test/blob/master/local/invoke.go
To invoke a go lambda locally we need to start the program. This can be done by building and running the go program and telling it what port to listen on.
Once its listening on a port it can be invoked using net/rpc
, this can be done by executing a go program like invoke.go
or by figuring out what kind of jsonrpc over tcp net/rpc
is and invoking it directly from node.js
Create a TestingLogger
and hookup STDOUT/STDERR to it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.