Numerous Philanthropic Misanthropes

    aglex

    2.0.0 • Public • Published

    aglex

    Aglex is a support tool for building serverless web applications using Amazon API Gateway, AWS Lambda and Express.

    Build Status Build Status Coverage Status Dependency Status bitHound Code

    No more new frameworks for Lambda + API Gateway!

    Express is the most famous web framework for Node.js. Now you can use the same way to develop your API Gateway-Lambda web app.

    UPDATE: now 2.x uses aws-serverless-express and new config yaml.

    Installation

    Global install

    $ npm install aglex -g

    or install and add to current package.

    $ npm install aglex --save-dev

    Features

    Aglex is not a web framework, just a small CLI tool which provides following features.

    • Generate a small lambda handler code
    • Create, update lambda function
    • Add execute-api permission to the function
    • Create, update and deploy API

    Quick start

    1. Start your app with express-generator.
    $ npm install express-generator -g
    $ express myapp
    cd myapp && npm install
    1. Modify routes/users.js to respond JSON data.
    @@ -3,7 +3,7 @@ 
     
     /* GET users listing. */
     router.get('/', function(req, res, next) {
    -  res.send('respond with a resource');
    +  res.json({message: 'respond with a resource'});
     });
     
     module.exports = router;
    1. Generate config yaml
    $ aglex generate config > aglex.yml

    Edit it to match your environment.

    @@ -18,14 +18,14 @@ 
       Runtime: nodejs4.3
       MemorySize: 128
       Timeout: 60
    -  FunctionName: YOUR_LAMBDA_FUNCTION_NAME
    -  Description: YOUR_LAMBDA_DESCRIPTION
    -  RoleName: YOUR_LAMBDA_EXECUTION_ROLE # Role ARN will generate from RoleName automatically
    +  FunctionName: myapp
    +  Description: myapp
    +  RoleName: lambda-myapp # Role ARN will generate from RoleName automatically
     
     ## API Gateway configuration
     apiGateway:
       swagger: 2.0
       info:
    -    title: YOUR_API_NAME
    -    description: YOUR_API_DESCRIPTION
    +    title: myapp
    +    description: myapp
       basePath: /prod
       schemes:
         - https
    1. Generate lambda handler code and install aws-serverless-express
    $ aglex generate lambda-handler > lambda.js
    $ npm install -S aws-serverless-express
    1. Create lambda zip
    $ zip -r lambda.zip app.js lambda.js routes views node_modules

    Use Gulp/Grunt if you want to do more tasks.

    1. Create/update your lambda function
    $ aglex --config aglex.yml lambda update --zip lambda.zip

    Create IAM Role for Lambda function lambda-myapp before execution.

    1. Add execute permission to your lambda function (first time only)
    $ aglex --config aglex.yml lambda add-permission
    1. Create/update API
    $ aglex --config aglex.yml apigateway update
    1. Create stage and deploy API
    $ aglex --config aglex.yml apigateway deploy --stage dev

    For more information, please see wiki docs.

    See Also

    Install

    npm i aglex

    DownloadsWeekly Downloads

    0

    Version

    2.0.0

    License

    MIT

    Last publish

    Collaborators

    • u-minor