Reputation: 143
I would like to use the AWS Serverless Express in my local environment in order to use a Lambda function easily.
The npm run local
doesn't start a web server but rather executes the Lambda function once with the api-gateway-event.json
file.
Does anyone know some tools that allows local development with a web server that executes a Lambda function? Are there any best practices in doing so?
Upvotes: 2
Views: 2592
Reputation: 91
Checkout the app.local.js
script in the basic-starter
example in the AWS Serverless Express project here.
This is a local version of the app file that contains:
const app = require('./app')
const port = 3000
app.listen(port)
console.log(`listening on http://localhost:${port}`)
You then run your local instance with the following command:
node app.local.js
For more information on working locally with AWS services and the deployment process around it, this article may help too: Deploy a REST API using Serverless, Express and Node.js
Upvotes: 1