Task 3 (First API with AWS API Gateway and AWS Lambda)#1
Open
mrCrab2024 wants to merge 2 commits intomainfrom
Open
Task 3 (First API with AWS API Gateway and AWS Lambda)#1mrCrab2024 wants to merge 2 commits intomainfrom
mrCrab2024 wants to merge 2 commits intomainfrom
Conversation
Lindar90
approved these changes
Sep 29, 2022
| import { Product } from '@functions/ProductType'; | ||
|
|
||
| export const findProduct = (arr: Product[], id: string) => | ||
| arr.find((product) => product.id === id) ?? 'product not found'; |
There was a problem hiding this comment.
I'd suggest returning null for a not found product. It'd be more expected.
|
|
||
| const getProductsById = async (event: APIGatewayProxyEvent) => { | ||
| const { productId } = event.pathParameters; | ||
| return formatJSONResponse(findProduct(products, productId)); |
There was a problem hiding this comment.
If a product is not found, it would be appropriate to return 404 status code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Service done
Link to Product Service API - https://cm3jpo1x3b.execute-api.eu-west-1.amazonaws.com/dev/products
Link to FE website - https://d3pqms05kkm99n.cloudfront.net/
Link to FE PR - mrCrab2024/shop-angular-cloudfront#2
PR for FE
Product schema:
Product = {
count: number;
description: string;
id: string;
price: number;
title: string;
cover: string;
};
Self-checking:
Evaluation criteria (each mark includes previous mark criteria)
1 - Product Service Serverless config contains configuration for 2 lambda functions, API is not working at all, but YAML configuration is correct
2 - The getProductsList OR getProductsById lambda function returns a correct response (POINT1)
3 - The getProductsById AND getProductsList lambda functions return a correct response code (POINT2)
4 - Your own Frontend application is integrated with Product Service (/products API) and products from Product Service are represented on Frontend. AND POINT1 and POINT2 are done.
Additional (optional) tasks
+1 - Async/await is used in lambda functions
+1 - ES6 modules are used for Product Service implementation
+1 - Custom Webpack/ESBuild/etc is manually configured for Product Service. Not applicable for preconfigured/built-in bundlers that come with templates, plugins, etc.
Not implemented (All languages) - SWAGGER documentation is created for Product Service
Not implemented (All languages) - Lambda handlers are covered by basic UNIT tests (NO infrastructure logic is needed to be covered)
+1 (All languages) - Lambda handlers (getProductsList, getProductsById) code is written not in 1 single module (file) and separated in codebase.
+1 (All languages) - Main error scenarios are handled by API ("Product not found" error).
Total: 9