https://github.com/lambda-lambda-lambda/lambda-edge-server
:loop: AWS CloudFront Lambda@Edge function handler emulator.
https://github.com/lambda-lambda-lambda/lambda-edge-server
aws cloudfront emulator functions lambda-edge nodejs
Last synced: 11 days ago
JSON representation
:loop: AWS CloudFront Lambda@Edge function handler emulator.
- Host: GitHub
- URL: https://github.com/lambda-lambda-lambda/lambda-edge-server
- Owner: lambda-lambda-lambda
- License: mit
- Created: 2023-03-25T20:28:41.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2026-01-14T21:52:02.000Z (13 days ago)
- Last Synced: 2026-01-15T04:58:54.953Z (12 days ago)
- Topics: aws, cloudfront, emulator, functions, lambda-edge, nodejs
- Language: JavaScript
- Homepage:
- Size: 271 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# lambda-edge-server
[](https://badge.fury.io/js/lambda-edge-server) [](https://www.npmjs.com/package/lambda-edge-server) [](https://app.travis-ci.com/github/lambda-lambda-lambda/lambda-edge-server) [](https://packagephobia.com/result?p=lambda-edge-server) [](https://github.com/lambda-lambda-lambda/lambda-edge-server/releases) [](https://github.com/nuxy/no-ai-badge)
AWS [CloudFront Lambda@Edge](https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html) function handler emulator.
Provides a translation layer between [Node.js](https://nodejs.org) HTTP server and [Lambda](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-generating-http-responses.html) function response format. The goal is simplify local testing without the need for complex dependencies.
## Dependencies
- [Node.js](https://nodejs.org)
## Installation
Install this package using [NPM](https://npmjs.com):
$ npm install lambda-edge-server
## Lambda function handlers
The following `origin-request/origin-response` format is currently supported.
### Synchronous example
```javascript
/**
* @see AWS::Serverless::Function
*/
exports.handler = function(event, context, callback) {
const response = {
status: '200',
statusDescription: 'OK',
headers: {
'cache-control': [{
key: 'Cache-Control',
value: 'max-age=0'
}],
'content-type': [{
key: 'Content-Type',
value: 'text/html'
}]
},
body: 'Success',
};
callback(null, response);
};
```
### Asynchronous example
```javascript
/**
* @see AWS::Serverless::Function
*/
exports.handler = async function(event) {
const response = {
status: '200',
statusDescription: 'OK',
headers: {
'cache-control': [{
key: 'Cache-Control',
value: 'max-age=0'
}],
'content-type': [{
key: 'Content-Type',
value: 'text/html'
}]
},
body: 'Success',
};
return response;
};
```
## Developers
### CLI options
Launch [HTTP server instance](http://localhost:3000), run the function:
$ npm start ./path/to/script.js
Run [ESLint](https://eslint.org/) on project sources:
$ npm run lint
Run [Mocha](https://mochajs.org) integration tests:
$ npm run test
## References
- [Example origin request](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html#example-origin-request)
- [Example origin-response](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html#lambda-event-structure-response)
## Contributions
If you fix a bug, or have a code you want to contribute, please send a pull-request with your changes. (Note: Before committing your code please ensure that you are following the [Node.js style guide](https://github.com/felixge/node-style-guide))
## Versioning
This package is maintained under the [Semantic Versioning](https://semver.org) guidelines.
## License and Warranty
This package is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
_lambda-edge-server_ is provided under the terms of the [MIT license](http://www.opensource.org/licenses/mit-license.php)
[AWS](https://aws.amazon.com) is a registered trademark of Amazon Web Services, Inc.
## Author
[Marc S. Brooks](https://github.com/nuxy)