Skip to content

Task 8#7

Open
DamirSt wants to merge 10 commits into
mainfrom
task-8
Open

Task 8#7
DamirSt wants to merge 10 commits into
mainfrom
task-8

Conversation

@DamirSt
Copy link
Copy Markdown
Owner

@DamirSt DamirSt commented May 30, 2026

Task 8 PR Description

What was done?

  • Implemented Task 8 end-to-end for Cart Service on AWS.
  • Added infrastructure as code with CDK and moved it into this repository under cdk-infra.
  • Deployed NestJS Cart API to AWS Lambda with API Gateway proxy integration.
  • Added PostgreSQL RDS instance in a VPC with security groups allowing Lambda to connect on port 5432.
  • Added TypeORM integration and PostgreSQL entities:
    • carts: id (PK, generated), user_id (not null), status enum (OPEN, ORDERED), created_at, updated_at
    • cart_items: id (PK, generated), cart_id (FK -> carts.id), product_id, count, product_snapshot
  • Added DB connection configuration using ConfigService and environment variables.
  • Added secure credential loading from AWS Secrets Manager via DB_SECRET_ARN.
  • Passed DB connection environment variables from CDK to Lambda.
  • Fixed backend API Gateway CORS configuration so browser preflight and cross-origin requests work from CloudFront.
  • Fixed backend Lambda to connect to RDS PostgreSQL with SSL (resolved 502 runtime failures caused by DB connection rejection).
  • Updated cart API responses to include created_at and updated_at fields.
  • Integrated frontend cart interactions with Cart Service API.
  • Updated frontend cart flow to use backend endpoints for:
    • loading cart
    • updating cart item count
    • clearing cart
  • Extended frontend auth interceptor so cart requests include Authorization header.
  • Updated frontend environment configuration to point cart endpoint to deployed API.
  • Redeployed backend stack and frontend stack.

Additional scope

  • FE integration verified in AWS_FOR_JS/FE:
    • cart load from API
    • add product to cart
    • remove cart item / clear cart
    • cart total calculation in checkout/cart views
  • Added CORS configuration and API Gateway 4XX/5XX gateway responses with CORS headers.
  • Repo consolidation: cdk-infra is now inside nodejs-aws-cart-api.
  • Backend infrastructure changes:
    • API Gateway CORS preflight/default response behavior
    • Lambda environment configuration (DB_SSL=true)
  • Frontend deployment updates:
    • fresh build
    • S3/CloudFront deployment via CDK

Verification

  • Preflight request to cart endpoint returns 204 with CORS headers.
  • Authenticated GET to cart endpoint returns 200.
  • Cart PUT and GET responses include created_at and updated_at.
  • Frontend deployed and available via CloudFront.

Link to Cart Service API

Frontend URL

DamirSt added 10 commits April 6, 2026 14:44
…eady Features

- Replace mock data with real DynamoDB tables (products & stock)
- Implement complete CRUD API with GET /products, GET /products/{id}, POST /products
- Add comprehensive validation with proper 400 error responses
- Implement transaction-based product creation for data consistency
- Add structured JSON logging for better observability
- Standardize error handling with proper HTTP status codes
- Update frontend to display real stock counts from database
- Create database population scripts with test vinyl record data
- Add UUID generation for new products
- Implement CORS headers and proper API Gateway integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant