Architecture
AWS SAM compiles the template and deploys via CloudFormation, producing an API Gateway REST API backed by a single Lambda function running the Express app.dist/lambda.handler
API Gateway caching is enabled only in the production environment, with a 600-second TTL on GET endpoints.
The API Gateway stage prefix (
/qa, /staging, /production) is stripped from the path before the request reaches Express. The Lambda handler (src/lambda.ts) removes the stage segment from event.path so routes work identically across all environments.Prerequisites
- AWS CLI configured with valid credentials
- AWS SAM CLI installed
- Node.js >= 18 and npm >= 9
Deploy
Build for Lambda
This compiles TypeScript and copies
src/swagger.yaml to dist/ so the Lambda bundle includes the OpenAPI spec:Deploy to an environment
Use
--config-env to target a specific environment defined in samconfig.toml:Environments
The three environments are defined insamconfig.toml with the following parameters:
| Environment | Stack name | Cache | CACHE_TTL |
|---|---|---|---|
| QA | duitama-taxi-pricing-qa | Disabled | 0 |
| Staging | duitama-taxi-pricing-staging | Disabled | 0 |
| Production | duitama-taxi-pricing-production | Enabled (600 s on GET) | 600 |
us-east-1.
Cached endpoints (production only)
API Gateway caches responses for the following GET endpoints with a 600-second TTL:| Endpoint | Method |
|---|---|
/api/v2026/zones | GET |
/api/v2026/barrios | GET |
/api/v2026/rutas-especiales | GET |
/api/v2026/sector | GET |
/* — CachingEnabled: false).
Lambda configuration
These values are set globally intemplate.yaml under Globals.Function:
| Setting | Value |
|---|---|
| Runtime | nodejs20.x |
| Memory | 256 MB |
| Timeout | 10 seconds |
NODE_ENV | Resolved from NodeEnv parameter (qa, staging, or production) |
CACHE_TTL | Resolved from CacheTtl parameter |