0.1.0 • Published 9 months ago

lambda-edge-server v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

lambda-edge-server

npm version npm.io Build Status

AWS CloudFront Lambda@Edge function handler emulator.

Provides a translation layer between Node.js HTTP server and Lambda function response format. The goal is simplify local testing without the need for complex dependencies.

Dependencies

Installation

Install this package using NPM:

$ npm install lambda-edge-server

Lambda function handlers

The following origin-request/origin-response format is currently supported.

Synchronous example

/**
 * @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

/**
 * @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, run the function:

$ npm start ./path/to/script.js

Run ESLint on project sources:

$ npm run lint

Run Mocha integration tests:

$ npm run test

References

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)

Versioning

This package is maintained under the Semantic Versioning 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

AWS is a registered trademark of Amazon Web Services, Inc.

Author

Marc S. Brooks

0.1.0

9 months ago

0.0.6

10 months ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago