Coder Social home page Coder Social logo

sam-ts's Introduction

AWS Serverless Application Model TypeScript template

A simple AWS SAM template with TypeScript.

Folder structure

This project has the following folder structure:

.
├── README.md # This file
├── build # Build folder
│   └── hello-world # Each function has its own folder
│       ├── lambda.js
│       └── lambda.js.map # And each function has sourcemaps
├── jest.config.js # Jest configuration
├── package.json
├── src # Source code for all functions
│   └── hello-world # Sample function
│       ├── events # Sample event for local invocationn
│       │   └── event.json
│       ├── lambda.ts # Main file
│       ├── lib # Rest of code, including function business logic
│       │   └── main.ts
│       └── tests # Tests for business logic and all important files
│           └── main.test.ts
├── template.yaml # Main CloudFormation file 
├── webpack.config.js # Webpack config
├── yarn.lock
└── .eslintrc.js # ESLint config

Usage

To use this template, make sure you have the following prerequisites:

  • AWS profile
  • AWS SAM installed and configured
  • Node.js version 8 or more (version 12 is recommended)

Initialize a new project

To create a new project using this template, create a new folder, navigate to your new folder in your terminal, and run the following command:

sam init --location gh:serverlesspub/sam-ts

This will create a new AWS SAM project with the folder structure explained above.

Build TypeScript

To build TypeScript, run the following command:

npm run build

If you want to build a project and run the webpack bundle analyzer, run the following command:

npm run build-analyze

Deploy

To deploy the project, run the following command:

sam deploy --guided

This will run an interactive deployment process, save your configuration to the samconfig.toml file, and deploy the project to your AWS account.

NOTE: The samconfig.toml file is on git ignore list.

Run automated tests

To run Jest tests, use the following command:

npm run test

This command will run ESLint, and if there are no linting issues, it'll run Jest tests.

If you want to run ESLint without tests, use the following command:

npm run lint

Test and debug using SAM Local

TBA

License

MIT, see LICENSE.

sam-ts's People

Contributors

stojanovic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

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.