Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task 3. First API with AWS API Gateway and AWS Lambda #18

Open
Guria opened this issue Oct 18, 2022 · 0 comments · Fixed by #9, #10, #12, #13 or #14
Open

Task 3. First API with AWS API Gateway and AWS Lambda #18

Guria opened this issue Oct 18, 2022 · 0 comments · Fixed by #9, #10, #12, #13 or #14

Comments

@Guria
Copy link
Owner

Guria commented Oct 18, 2022

Task 3 assignment

Note for reviewers

  • I use this issue instead of PR to collect everything about this task and all referenced PR are merged already.
  • I use single monorepo with both BE and FE for a good reason: FE build uses outputs of BE stacks. Organizers have confirmed that it is acceptable.
  • This issue opened with a big delay for review, but:
  • Check Task 2. Serve SPA in AWS S3 and Cloudfront Services #3 or commit history if you want to learn more about setup and reasoning. Issues, PRs and each commit messages contain lot of details.
  • You can skip review of repo preparation and extra efforts. Listing it here just in case you might be interested.
  • Please provide your evaluation in comments and fill in the form.

Task 3 Artifacts

Task 3.prepare (Pull Requests #9, #10, #12)

  • Converted to monorepo
  • Set up serverless-compose
  • CloudFrontOriginAccessControl set to be more unique, so it can be deployed for different stages
  • ESLint adapted to monorepo usage
  • migrate from deprecated method in actions
  • extract models and mocks to shared module for future reuse

Task 3.1 (Pull Request #13)

✔️ Create a lambda function called getProductsList of Product Service which will be triggered by the HTTP GET method.
✔️ The requested URL should be /products.
✔️ The response from the lambda should be a full array of products.
✔️ This endpoint should be integrated with Frontend app for Product List Page representation

Additional tasks:
✔️ Async/await is used in lambda functions
✔️ ES6 modules are used for Product Service implementation
✔️ ESBuild is configured for Product Service.

Extra effort:

  • api gateway is defined as separate service to reuse for all future lambdas
  • app is build on deploy stage with forked scriptable plugin
  • api gateway url is passed to frontend app build

Task 3.2 (Pull Request #14)

✔️ Create a lambda function called getProductsById in Product Service which will be triggered by the HTTP GET method.
✔️ The requested URL should be /products/{productId}
✔️ The response from the lambda should be 1 searched product from an array of products (mock data should be used).

Additional tasks:
✔️ Lambda handlers (getProductsList, getProductsById) code is written not in 1 single module (file) and separated in codebase.

Extra effort:

  • This endpoint is integrated with Frontend app. New route and components set is created
  • Business logic moved from handler code to a service class

Task 3.swagger (Pull Request #15)

✔️ Swagger scheme is extracted from aws and published along with frontend app.
✔️ Swagger UI is added to the app temporarily. Will be in a separate bucket in future.

Task 3.unit-tests (Pull Request #16)

✔️ Implement tests separate for business logic service and for handlers.

Task 3.error-handle (Pull Request #17)

✔️ Main error scenarios are handled by API ("Product not found" error).

Task 3.cors (Pull Request #19)

  • frontend resources moved out to separate service
  • products-api and shop-frontend-app are using resource outputs to properly configure cors and frontend app
  • cover middify function with tests

Links to deployment

Deployments links removed since its outdated and there are newer tasks implemented.

Github Actions log: https://github.com/Guria/aws-js-practitioner/actions/runs/3271179800/jobs/5380650613#step:10:102

@Guria Guria linked a pull request Oct 18, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment