Code Monkey home page Code Monkey logo

auto-cdk's Introduction

Auto CDK

auto-cdk lets you generate an api gateway with lambda integrations based on the filesystem. It makes use of AWS CDK to generate cloudformation stacks, and Webpack for bundling and code-splitting.

Caveats

Currently this project only aims to build and package node/typescript-based integrations. It is on the roadmap to support more, but will not be available until a later version.

Quickstart

yarn add auto-cdk

Create an api directory and add a file to it that exports a function named handler:

$ mkdir api && touch api/index.ts
// api/index.ts

exports.handler = (event, ctx) => {
  return {
    statusCode: 200,
    body: 'hello world',
    headers: {
      'Content-Type': 'text/html'
    }
  }
}

Run:

$ yarn dev

You should now have webpack auto-compiling when your source changes, and a cdk stack that has been generated in cdk.out.

Bonus

If you install AWS sam-cli, you can run the api on localhost with the following:

$ sam local start-api cdk.out/*.template.json

View more examples here.

Features

  • Automatic CDK Stack Generation
  • Code-Splitting and Bundling with Webpack
  • Out of the box typescript support

Contributing

If you would like to make a contribution or learn more about running this project locally, please review the Contributing Documentation.

auto-cdk's People

Contributors

dependabot[bot] avatar wulfmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

auto-cdk's Issues

Add dev mode to enable hot reloading

When using sam-cli, the api will watch the asset directory to enable hot reload. In our case the asset directory is dist.

We need to create a dev webpack config that will auto-compile the source so that the live reload works.

Allow user to modify resource configuration

Currently when the generator encounters a directory, it creates a new api resource with the directory name and a default configuration.

The user may want to modify this configuration.

The proposed solution to this is to specify a config file that will not be mapped to a handler, but instead pulled in at resource creation time and passed in.

Add auto-database option

Add option to include a database in the default stack and pass the name as an env var to all handlers and assign relevant permissions to each handler.

Allow individual handler configuration

We want the users to be able to specify integration-specific configuration.

One way we could accomplish this is by allowing handlers to export a variable with configuration options.

Add support for authorizers

Unsure how we would implement this.

One idea is making authorizer a protected filename. Any file somedir/authorizer.ts would be mapped to an authorizer being created on the somedir resource.

Another option is to export an authorizer function from a handler.

Allow user to specify separate integration per method

Similar to #6, we would like to allow the user specify separate method lambdas.

We could accomplish this by automatically converting files named get, put? Etc into separate integrations that are then attached as their respective methods.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.