I have a mobile application backend developed with node.js express. I tried it to deploy it as lambda service. For that I created a Serverless Framework project (https://github.com/serverless). Previously I tested mobile app locally by starting express backend application. Now I can't find a method to test my mobile app locally without local backend. jaws run
command only run once I called it.
Is there any method to start the lambda function as a web service? Or is there any alternative to Serverless Framework?
Step 1: Download SAM local Windows Install SAM CLI using an MSI in either the 64 bit or 32 bit versions. Step 2: Verify that the installation succeeded and version with the command below. Step 3: Write your lambda function or clone it from Github to run locally, making sure to add Template. yaml on the root level.
You can invoke your AWS Lambda function locally by using the sam local invoke AWS SAM CLI command and providing the function's logical ID and an event file. Alternatively, sam local invoke also accepts stdin as an event. For more information about events, see Event in the AWS Lambda Developer Guide.
It doesn't look like there's way to do this right now, but version 1.4.0 is about to be released and, among other things, it should include a new command "jaws serve" which should address your problem.
Here's the PR: https://github.com/jaws-framework/JAWS/pull/269
UPDATE: you can now use the new serverless-serve plugin for this.
UPDATE 2: serverless-serve hasn't been updated in a while, it looks like serverless-offline is a much better option now to emulate Lambda functions.
You can now use lambda-local.
Install it like this:
sudo -H npm install -g lambda-local
Add your parameters as a JSON object to a file, in this example event.json
, and call the index.js
file like this:
lambda-local -l index.js -h handler -e event.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With