Skip to content

aws-lambda-template-generator/ts-simple-api-proxy-template

Repository files navigation

ts-simple-api-proxy-template

AWS Lambda function template with TypeScript for creating a simple API proxy.The example function simply retrieves data from an API endpoint and return it from API gateway.

Tools and Framework

  • Serverless
  • Webpack
  • Typescript
  • Jenkins
  • Mocha

Setup

(1) Install all modules

npm i

Running Test

It uses mocha for unit & integration tests. Istanbul for coverage.

# unit test
npm test
# integration test
npm run integration

Deployment

  1. Jenkins

The project includes an example Jenkinsfile. Update according to your Jenkins setup for pipeline.

  1. From local machine

Use npm command and we can pass arguments as below. Alternatively, we can use sls deploy command.

# nonprod
sls deploy --stage nonprod # if you have serverless installed globally (npm i -g serverless)
npm run deploy -- --stage nonprod

# prod
sls deploy --stage prod
npm run deploy -- --stage prod

To remove, run the command below:

sls remove --stage nonprod
# or
npm run remove -- --stage nonprod

Checking endpoint

curl -H "x-api-key: <api key" -X GET https://url

Memory Optimisation

We recommend to use AWS Lambda Power Tuning to optimise the memory size allocation (see details here).

Reference

Tools

Configuration & Miscellaneous Reference

About

Typescript Lambda function template for a simple API proxy service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published