Skip to content

A template for developing AWS Lambda functions using Node.js and TypeScript with the AWS Serverless Application Model (SAM)

License

Notifications You must be signed in to change notification settings

john-james-gh/aws-sam-ts-template

Repository files navigation

🦄 AWS SAM Template for Node.js + TypeScript Lambda

Welcome to the AWS SAM TypeScript Lambda Template. A clean, modern starting point for building AWS Lambda functions with Node.js and TypeScript, powered by the AWS Serverless Application Model (SAM). 🚀

This template helps you quickly spin up serverless projects with best practices baked in: strict type checking, linting, testing, and formatting included.


⚡️ Features

✅ AWS SAM-based Lambda setup
✅ TypeScript for type safety and modern development
✅ 🪵 Pino for fast, structured logging
✅ 🏗️ esbuild for super-fast builds
✅ ✅ Jest testing with TS + globals support
✅ ESLint + Prettier for clean, consistent code
✅ Handy scripts for linting, formatting, testing, and type-checking


🛠️ Getting Started

📦 Build the project

sam build

🧪 Local invoke your function

sam local invoke MyTemplateGetAllFunction --event events/get-all-event.json

🌐 Remote invoke your function

sam remote invoke MyTemplateGetAllFunction --stack-name aws-sam-ts-template

🚀 Start the local API Gateway

sam local start-api

✅ Validate the SAM template

sam validate --lint

📤 Deploy the stack (guided mode)

sam deploy --guided

🧹 Available NPM Scripts

Script Purpose
npm run type-check Run TypeScript strict type checking
npm run lint Lint code with ESLint (auto-fix enabled)
npm run test Run tests with Jest
npm run format Format codebase with Prettier

📂 Project Structure

├── events/                 # Sample event payloads for testing
├── src/                    # Lambda function source code
├── tests/                  # Unit tests
├── template.yaml           # AWS SAM template definition
├── samconfig.toml          # Deployment configuration
├── tsconfig.json           # TypeScript configuration
├── eslint.config.js        # ESLint config
├── jest.config.js          # Jest config
├── .prettierrc             # Prettier config

🚀 Why Use This Template?

💡 "Don't reinvent the wheel — but make sure your wheel isn't square."

✅ Modern tooling
✅ Fast feedback loop
✅ Clean DX (Developer Experience)


📜 License

MIT @ John James


"Horses don’t stop, they keep goin’." 🐎

About

A template for developing AWS Lambda functions using Node.js and TypeScript with the AWS Serverless Application Model (SAM)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published