Skip to content

feat: integrate TypeORM with PostgreSQL and AWS Secrets Manager for d… - #1

Open
DamirSt wants to merge 1 commit into
mainfrom
task-8
Open

feat: integrate TypeORM with PostgreSQL and AWS Secrets Manager for d…#1
DamirSt wants to merge 1 commit into
mainfrom
task-8

Conversation

@DamirSt

@DamirSt DamirSt commented May 30, 2026

Copy link
Copy Markdown
Owner

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

…atabase configuration

- Added TypeORM and PostgreSQL dependencies to package.json.
- Created CartEntity and CartItemEntity for cart management.
- Implemented database connection using AWS Secrets Manager to retrieve credentials.
- Refactored CartService to use TypeORM for cart operations.
- Updated CartController to handle cart items with timestamps.
- Enhanced error handling and response structure in cart operations.
- Introduced serverless express integration for AWS Lambda deployment.
- Updated models and types to accommodate new cart structure and order processing.
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