Skip to content

Task 4 (Integration with NoSQL Database)#3

Open
Tati-Moon wants to merge 5 commits intomainfrom
task-4
Open

Task 4 (Integration with NoSQL Database)#3
Tati-Moon wants to merge 5 commits intomainfrom
task-4

Conversation

@Tati-Moon
Copy link
Owner

@Tati-Moon Tati-Moon commented Jun 23, 2024

Task 4

https://github.com/rolling-scopes-school/aws/blob/main/aws-developer/04_integration_with_nosql_database/task.md

Links

curl -X POST https://s0ob4l26k9.execute-api.us-east-1.amazonaws.com/prod/products \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
  "title": "some new title",
  "description": "some new description",
  "price": 11,
  "count": 22
}'

Evaluation Criteria

  • 100/100

###Additional Scope (+30 points)

Task 4.1

  1. Created two DynamoDB tables:
    • products table with fields:
      • id (uuid, Primary key)
      • title (text, not null)
      • description (text)
      • price (integer)
    • stocks table with fields:
      • product_id (uuid, Foreign key referencing products.id)
      • count (integer, representing total stock count)

img1
2. Added items.

img2

Task 4.2

  1. Updated AWS CDK Stack:

    • Created DynamoDB tables (products and stocks).
    • Updated Lambda’s environment variables.
  2. Integrated getProductsList Lambda:

    • Returns list of products via GET /products endpoint from DynamoDB.
    • Implemented joining of products and stocks tables.

img6

  1. Implemented Product model:
    • Combined product and stock data into a single model (Product).

image

Task 4.3

  1. Created createProduct Lambda function:
    • Triggered by HTTP POST method.
    • Implements logic to create a new item in products table.

img5

  1. Curl for add new product:
curl -X POST https://s0ob4l26k9.execute-api.us-east-1.amazonaws.com/prod/products \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
  "title": "some new title",
  "description": "some new description",
  "price": 11,
  "count": 22
}'

Task 4.4

  1. Committed changes to new branch

img4

Additional Tasks

  • Error Handling:
    • Implemented error handling:
      • Returns 400 status code for invalid product data.
      • Returns 500 status code for any unhandled errors.

image

  • Logging:

    • Added console.log for each incoming request and their arguments.
  • Transactions:

    • Implemented transaction-based creation of products and stocks to ensure data integrity.

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