Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Running Express apps in AWS Lambda | ||
|
||
This is a simple example that shows how to deploy an existing [Express](http://expressjs.com/) application, with minimal changes, to AWS Lambda. | ||
|
||
## Running the example | ||
|
||
1. run `npm install` to grab the dependencies | ||
2. run `npm run generate-proxy` to create a simple proxy API for the express app | ||
3. run `npm run deploy` to send everything up to AWS Lambda | ||
|
||
The third step will print out a URL you can use to access the express app. | ||
|
||
## Updating the app | ||
|
||
1. Change [`app.js`](app.js) | ||
2. (Optionally) use `npm install <PACKAGE NAME> -S` to install additional dependencies (always save them to `package.json` using `-S`) | ||
3. Run `npm run update` to send the new version up to AWS. No need to generate the proxy again | ||
|
||
## More information and limitations | ||
|
||
See the [Running Express Apps in AWS Lambda](https://claudiajs.com/tutorials/serverless-express.html) tutorial. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict' | ||
const express = require('express') | ||
const app = express() | ||
|
||
app.get('/', (req, res) => { | ||
res.sendFile(`${__dirname}/index.html`) | ||
}) | ||
|
||
// app.listen(3000) // <-- comment this line out from your app | ||
|
||
module.exports = app // export your app so aws-serverless-express can use it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Serverless Express Example</title> | ||
</head> | ||
<body> | ||
<h1>Hello from Express</h1> | ||
<p>this page is served by Express, through | ||
<a href="https://www.npmjs.com/package/aws-serverless-express">aws-serverless-express</a> and | ||
<a href="https://claudiajs.com/tutorials/deploying-proxy-api.html">Claudia.JS Proxy API</a></p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "claudia-express", | ||
"version": "1.0.0", | ||
"description": "Example application for running a Node Express app on AWS Lambda using Amazon API Gateway.", | ||
"main": "lambda.js", | ||
"scripts": { | ||
"deploy": "claudia create --handler lambda.handler --deploy-proxy-api --region us-east-1", | ||
"update": "claudia update", | ||
"generate-proxy": "claudia generate-serverless-express-proxy --express-module app" | ||
}, | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"aws-serverless-express": "^1.1.0", | ||
"express": "^4.14.0" | ||
}, | ||
"devDependencies": { | ||
"claudia": "^2.1.0" | ||
} | ||
} |