user3933324
user3933324

Reputation: 143

AWS Serverless Express in local environment

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

Answers (1)

Dean
Dean

Reputation: 91

Checkout the app.local.js script in the basic-starter example in the AWS Serverless Express project here.

app.local.js

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}`)

local command

You then run your local instance with the following command:

node app.local.js

deployments

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

Related Questions