You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+120-39
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,18 @@
1
1
# convert-lambda-to-express
2
2
3
-
Production-ready package to run your lambda workloads as an express server. Build with the developer (me :P) in mind and makes development of lambda api's a breeze. This package was developed because the other options available for running lambdas, like [sam local start-api](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-local-start-api.html)[serverless-offline](https://github.com/dherault/serverless-offline) or [docker-lambda](https://github.com/lambci/docker-lambda), require docker containers and are VERY slow hot-reloading or do not provide that feature at all (how does one dev without hot reload these days?!?!).
3
+
Production-ready package to run your lambda workloads as an express server. Built with both developers and enterprise in mind.
4
+
5
+
`convert-lambda-to-express` provides fully features `event` and `context` objects to your handlers and there should be no need to modify your existing code. If you rely on the `ENVIRONMENT` variables that lambda provides, those are accounted for as well.
4
6
5
7
Running apiGateway/lambda locally during development can be a challenge (to say the least). The other options out there are either too slow or too complicated. This package aims to solve this problem by providing a simple way to run your api locally. It allows you to wrap your handlers and serve them from an express server.
6
8
7
-
`convert-lambda-to-express` provides fully features `event` and `context` objects to your handlers and there should be no need to modify your existing code. If you rely on the ENVIRONMENT variables that lambda provides, those are accounted for as well.
9
+
Makes development of lambda api's a breeze. This package was developed because the other options available for running lambdas, like [sam local](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-local-start-api.html), [serverless-offline](https://github.com/dherault/serverless-offline) or [docker-lambda](https://github.com/lambci/docker-lambda), require docker containers. They are all VERY slow hot-reloading or do not provide that feature at all (how does one dev without hot reload these days?!?!).
10
+
11
+
There are even some great use cases for migrating workloads away from Lambda and this is the project for you.
8
12
9
-
There are even some great use cases for migrating workloads away from Lambda and this is the project for you. Hate your, now baked-in, vendor lock with the non-portable lambda function signature? Have you found that concurrency limits with very choppy traffic for extremely high workloads make it hard to reserve concurrency for and just want to use an auto-scaling group or kubernetes cluster now that you've grown? Do you have long running, but very low resource tasks that end up costing an arm and leg on Lambda. Depending on your specifics it can end up being much more effective/cost-efficient to run you system on EC2 or on a kubernetes cluster. Rest assured this is a production-ready package that is built for a bulletproof base with express.
13
+
Hate your, now baked-in, vendor lock and the non-portable lambda function signature? Have you found that concurrency limits for very choppy traffic and extremely high workloads hard to reserve concurrency for? Just want to use an auto-scaling group or kubernetes cluster now that you've grown? Do you have long running, but very low resource tasks that end up costing an arm and leg on Lambda. Depending on your specifics it can end up being much more effective/cost-efficient to run you system on EC2 or a kubernetes cluster. Rest assured this is a production-ready package that is built for a bulletproof base with express.
10
14
11
-
If you love this package and want to [thank me](https://www.paypal.com/donate?hosted_button_id=HCF76TA62TXJW), or contract with me, you can find me at [Matthew Keil](https://www.linkedin.com/in/matthew-keil/). I specialize in DevOps, Security(SecOps) and Crypto/Solidity development. Open-source for the win!
15
+
If you love this package and want to [thank me](https://www.paypal.com/donate?hosted_button_id=HCF76TA62TXJW), or contract with me, you can find me at [Matthew Keil](https://www.linkedin.com/in/matthew-keil/). I specialize in Crypto/Solidity, DevOps and Security(SecOps) development. Open-source for the win!
You can import the `addToDevServer` into your cdk constructs and add the handlers during run time. This was the designed use case. See [`matthewkeil/full-stack-pattern`](https://github.com/matthewkeil/full-stack-pattern) for an example. Also works well with sam templates or any other method for programmatically building the handlers array in the example below. In the cdk instance, instead of calling app.synth() call startDevServer() and it will give you a hot reloading api.
|`resourcePath`|defaults to `/{proxy+}` Placed in ENVIRONMENT, `event` and `context`|
168
+
|`handler`|`filename.exportName` format. Placed in ENVIRONMENT|
169
+
|`codeDirectory`|used to import handler and for watching code changes|
170
+
|`environment`|environment variables|
90
171
|`functionName`|optional, defaults to `convert-lambda-to-express`. Placed in ENVIRONMENT, `event` and `context`|
91
-
|`resourcePath`|optional, defaults to `/${proxy+}` Placed in ENVIRONMENT, `event` and `context`|
92
-
|`profile`|optional, defaults to `default`. profile from `~/.aws/credential` to use. Adds tokens to AWS_TOKEN, AWS_SECRET_TOKEN, AWS_SESSION_TOKEN|
93
-
|`region`|optional, AWS region, default to `us-east-1`. adds AWS_REGION to ENVIRONMENT|
94
-
|`accountId`|optional, aws account id. Placed in ENVIRONMENT|
172
+
|`functionVersion`|optional, defaults to `$LATEST`. Placed in ENVIRONMENT|
95
173
|`timeoutInSeconds`|optional, default to `3`. watchdog timer that mimics lambda's timeout|
96
-
|`stage`|optional, defaults to `dev`. Passed in `event`|
97
-
|`isBase64Encoded`|optional, default to `false`. Passed in to handler `event`|
98
-
|`handler`|optional, in `filename.exportName` format. Placed in ENVIRONMENT|
99
-
|`nodeModulesPath`|optional, path to local node_modules folder. Placed in ENVIRONMENT|
100
174
|`identity`|optional, CognitoIdentity object, see [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7b62f878cc218c8e94e6efafa55cea6796b501f7/types/aws-lambda/handler.d.ts#L124). Passed in `context`|
101
175
|`clientContext`|optional, ClientContext object, see [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7b62f878cc218c8e94e6efafa55cea6796b501f7/types/aws-lambda/handler.d.ts#L129). Passed in `context`|
176
+
|`nodeModulesPath`|optional, path to local node_modules folder. Placed in ENVIRONMENT|
177
+
|`stage`|optional, defaults to `dev`. Passed in `event`|
178
+
|`isBase64Encoded`|optional, default to `false`. Passed in to handler `event`|
102
179
|`finalize`|optional, clean-up function that is called at the end of each request|
180
+
|`accountId`|optional, aws account id. Placed in ENVIRONMENT|
181
+
|`region`|optional, AWS region, default to `us-east-1`. adds AWS_REGION to ENVIRONMENT|
182
+
|`profile`|optional, defaults to `default`. profile from `~/.aws/credential` to use. Adds tokens to AWS_TOKEN, AWS_SECRET_TOKEN, AWS_SESSION_TOKEN|
183
+
|`credentialsFilename`|optional, defaults to `~/.aws/credential`|
103
184
|`logger`|optional, winston Logger object. will default to the console object if not present|
104
-
|`defaultHeaders`|optional, headers that should be applied to all responses|
185
+
|`defaultResponseHeaders`|optional, headers that should be applied to all responses|
0 commit comments