A starter project for building AWS Lambda APIs with TypeScript, Serverless Framework, and DynamoDB.
- Serverless Framework (AWS)
- TypeScript
- Webpack
- Jest
- ESLint + Prettier
- Serverless Offline
- Node.js and npm
- AWS account and IAM credentials
- Serverless Framework CLI
- Install dependencies:
npm install- Create local environment files:
cp /tmp/workspace/devmeireles/serverless-boilerplate/env.yml.example /tmp/workspace/devmeireles/serverless-boilerplate/env.yml
cp /tmp/workspace/devmeireles/serverless-boilerplate/.env.example /tmp/workspace/devmeireles/serverless-boilerplate/.env- Configure AWS credentials for Serverless (example profile name used by this repo):
serverless config credentials \
--provider aws \
--key YOUR_AWS_ACCESS_KEY_ID \
--secret YOUR_AWS_SECRET_ACCESS_KEY \
--profile serverless-boilerplateNever commit real credentials to
.env,env.yml, or source code.
- Update
env.ymlvalues for each stage (default,dev,stage,prod) with your own configuration.
Before running locally or executing integration tests, deploy the DynamoDB table for the target stage.
npm run deploy:database:devOther stage commands:
npm run deploy:database:stagenpm run deploy:database:prod
npm run start:devThis starts serverless offline via nodemon and watches the src folder.
POST /interactionsGET /interactionsGET /interactions/{id}PUT /interactions/{id}DELETE /interactions/{id}
Run tests:
npm run testRun tests with coverage:
npm run test:coveragenpm run lint:fix— lint and auto-fix TypeScript filesnpm run format:fix— format TypeScript, JavaScript, JSON, and Markdown
- Local/dev environment changes may affect real AWS resources depending on your configured table names.
- Double-check
MAIN_TABLEand stage-specific values before running deploy commands. - For AWS credentials setup details, see the Serverless documentation.