Skip to content

Conversation

bwire
Copy link
Owner

@bwire bwire commented Jun 12, 2023

Task 4.1.

  • Two tables created in AWS DynamoDB (products, stocks) and filled with test data;
  • A sh-script provided to fill up tables: ./scripts/dynamo/fill-tables.sh;

Task 4.2

  • New environment variables from table names created and all lambdas configured to use them;
  • lambdas get data form the database. Product-service API link: Product-service API

Task 4.3

{ "id": "6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b", "title": "Just test", "description": "Improving the Design of Existing Code shed light on the refactoring process, describing the principles and best practices for its implementation.", "price": 25, "count": 8 }

Additional tasks:

  • POST /products lambda functions returns error 400 status code if product data is invalid - done. For the sake of simplicity - all fields in the payload are checked including the id - which is expected from the client-side! Example error (https://1lwpgiz791.execute-api.eu-west-1.amazonaws.com/products/23):
    { "message": "Product with id 23 not found" };
  • All lambdas return error 500 status code on any error (DB connection, any unhandled error in code) - done. One can observe it in the code of every lambda handler - their code are wrapped in try/catch blocks and every catch process different unexpected errors (return errorResponse(err);). errorRespose uses status code 500 by default;
  • All lambdas do console.log for each incoming requests and their arguments - done. Can be observed in every lambda handler (./src/handlers): console.log('Incoming request', event);
  • Use RDS instance instead of DynamoDB tables. Do not commit your environment variables to github! - done. RDS instance for Postgres configured. Scripts for creating tables and adding data can be found here: ./scripts/postgres. To switch between DynamoDB and Postgres it is enough to flip USE_NOSQL_DB environment variable in every lambda or just redeploy the stack with the new value, for example USE_NOSQL_DB=false- in this case the Postgres-specific implementation will be used.
  • Transaction based creation of product - done for both DynamoDB and Postgres implementations (createProduct only - no transactional read).

Swagger documentation updated and can be found here:
./product-api.json
Front-end (uses the last backend code and data): https://d1eot7ucp9tkae.cloudfront.net
Front-end PR (just in case): bwire/nodejs-aws-shop-react#2

@bwire bwire merged commit 6ae1313 into master Jun 17, 2023
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