Example of the simple AWS serverless application with DynamoDB, Typescript and tests.
- Lambdas in typescript (see src/handlers/)
- Working with DynamoDB (see src/database/taskRepository.ts)
- ZOD validation library
- Local environment (run
npm run offline
) - Serverless with configuration in typescript (see serverless.ts)
- Tests on offline environment and local database (run
npm run test:offline
, see src/handlers/addTask.test.offline.ts) - Tests on AWS (run
AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... npm run test:e2e
, see src/handlers/addTask.test.e2e.ts) - Simple custom authorizer, allows to add multiple access tokens and define custom allowed endpoints (see src/handlers/authorizer.ts)
- AWS SDK version 3 (see src/database/createDynamoDbDocumentClient.ts)
- Source maps for debugging typescript in AWS
- XRAY
- Clone project
- Install dependencies
> npm ci
- Install local database
> npx sls dynamodb install
- Run offline
> npm run offline
- Send POST request to
POST http://localhost:3000/task
data:
{
"description": "my value"
}
Run:
> AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... npm run start
- add endpoints for remove task, list tasks and update task
- add tests and lint to GitHub actions