My personal template for Lambda APIGW applications, this project was made in Node.js with TypeScript using Express as the HTTP framework, adapted to run in AWS Lambda with integration to API Gateway. Locally, it uses the Serverless Framework with serverless-offline to simulate the AWS environment.
- Node.js 20+
- TypeScript
- Express
- AWS Lambda (via
@codegenie/serverless-express) - Serverless Framework
- serverless-offline (to run locally)
Before getting started, you need to have the following installed:
- Node.js v20 or later
- Yarn
- Serverless Framework (
npm install -g serverless)
Clone the repository and install the dependencies:
git clone https://github.com/felipedmsantos95/lambda-apigw-template.git
cd lambda-apigw-template
yarnThe project uses Serverless Offline to simulate the behavior of the API Gateway and Lambda locally.
Compile the project and start the server:
yarn offlineThis command compiles the TypeScript code and runs Serverless Offline without the stage suffix (
/dev,/local), allowing direct access via/.
Once the project is running, access:
GET http://localhost:3000/
Expected response:
Hello from Express + AWS Lambda using @codegenie!
src/
├── index.ts # Local entry point
├── lambda.ts # AWS Lambda handler
├── server.ts # Separate Express app (reusable)
tsconfig.json # TypeScript configuration
serverless.yml # Serverless Framework configuration
- To simulate other endpoints, add new routes in
src/server.ts. - The
src/lambda.tsfile transforms Express into an AWS Lambda handler. - The
serverless.ymlfile is configured to work with theserverless-offlineplugin.
Feel free to open PRs, issues, or adapt the template to your needs!