Commit f698871
authored
rolling-scopes-school#9: Application deployment via Elastic Beanstalk (Docker platform) (#3)
* fix: add missing properties to a user's cart
* feat: use esbuild to compile project
* feat: wrap nest app as serverless function
details: create aws cdk stack to deploy lambda handler
* feat: add Prisma ORM to the project
details: define cart and cart_items db schemas
* feat: add postgres docker image for local testing
* feat: add Product model to db schema
* feat: add Prisma seed script to fill db with initial data
* feat: add users table with relation to cart
* fix: indicate correct entry point for cart lambda handler
* refactor: rename prisma models properties
* test: actualize e2e test
* refactor: remove rows in cascade on removing relations
* refactor: drop 'count' column in products table
* feat: use Postgres to store data in cart service
* tests: add integration test for Prisma service
* feat: users service uses prisma service to store/retrieve data
* fix: does not include cdk into source files
* feat: cart controller uses basic auth for get/put methods
details: add e2e tests for cart controller
* feat: add possibility to create orders
details:
1. create 'orders' table
2. update 'checkout' endpoint in cart controller
3. create order via prisma transaction
4. add integration tests for order creation
5. add e2e tests for order creation
* feat: create rest api with proxy method to pass all the data to cart handler
details: reference already existing db instance by its attributes
* fix: include prisma linux query lib into cart lambda source code
* refactor: drop 'products' table
details: cart service should not save products data as its already present in 'products' service, so it will operate 'product_id'/'count' only
* refactor: remove jwt/local auth strategies (use basic only)
* refactor: bootstrap nest application in separate module
details: clearly split server (listening to a port) and serverless implementations
* feat: give final shape to input/output of cart controller/service
details: cart creation/update/checkout implemented fully
* refactor: remove 'calculateCartTotal' as there's no info about a product price
* tests: update integration/e2e tests of cart service
* refactor: squash prisma migrations
* refactor: resolve dest of prisma query lib relatively to output dir
* refactor: use webpack to build nest.js application
details: esbuild does not respect 'experimentalDecorators' which are heavily used by nest.js for injection (see details at https://esbuild.github.io/content-types/#tsconfig-json)
* refactor: remove PrismaModule import in AuthModule
* feat: create rds db instance (postgres) via aws cdk
* fix: correct supertest import in tests
* feat: ignore 'cdk*' files and folders with prettier
* feat: enable source maps for aws cdk build
* feat: create network construct for managing connections between lambda and rds
details:
1. network constructs creates security groups to establish connection between lambda and rds db instance
2. db instance endpoint host/port are used to create database url passed as end to lambda handler
3. lambda handler is deployed to one AZ only (the same availability zone is used by db instance)
* refactor: take server port from env var
* refactor: rename db env vars to conform with aws cdk
* feat: add scripts to deploy/seed local/remote db instance with prisma
* docs: add documentation for aws cdk stack
* refactor: move aws cdk account id/region env vars to config
* tests: actualize aws cdk unit tests
* fix: correct formatting in cdk/README.md
* fix: use .env.local or .env.remote depending where db changes are required
* docs: add documentation for cart service
* feat: add method to delete cart of a user
* docs: add mentioning of .env file used for local development by default
* tests: add Postman collection to test Cart service
details: update README with info about Postman collection
* feat: compile server and serverless implementations
* feat: add Dockerfile to build server
details: use Docker Compose to run cart-api comprising of postgres and nest.js app
* refactor: create prisma:deploy and prisma:seed scripts to run with diff envs
* feat: compile prisma seed script
* docs: add comments to .dockerignore
* feat: create Dockerfile to build image with cart api server
* fix: export port as part of Elastic Beanstalk platform Docker requirements
* feat: add cloudwatch streaming config for Elastic Beanstalk application
* feat: add .ebignore as part of Elastic Beanstalk application config
* feat: add npm scripts for Elastic Beanstalk application
details:
1. env-cmd vars expansion is used to pass DATABASE_URL to env vars of EB application
2. Dockerfile is used to build image on EC2 instance (docker-compose.yml is ignored by .ebignore)
* fix: include .ebextensions into Elastic Beanstalk deploy
* feat: remove public access to RDS DB instance
* refactor: remove internet <-> RDS security group
* refactor: change eb instance type to t2.micro
details: t2.micro falls under Free Tier 750h/month rule in eu-central-1 (Frankfurt) region
* feat: add http api to proxy requests from HTTPS endpoint to EB HTTP endpoint
* fix: add default headers to http proxy api to support CORS
* docs: add information about docker/eb npm scripts1 parent 0eb1826 commit f698871
18 files changed
Lines changed: 225 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | | - | |
11 | 9 | | |
12 | | - | |
13 | 10 | | |
14 | | - | |
15 | 11 | | |
16 | | - | |
17 | 12 | | |
18 | | - | |
19 | 13 | | |
20 | | - | |
21 | 14 | | |
22 | | - | |
23 | 15 | | |
24 | | - | |
25 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
26 | 23 | | |
27 | 24 | | |
28 | 25 | | |
29 | 26 | | |
30 | 27 | | |
31 | | - | |
32 | | - | |
| 28 | + | |
| 29 | + | |
33 | 30 | | |
34 | 31 | | |
35 | 32 | | |
| |||
44 | 41 | | |
45 | 42 | | |
46 | 43 | | |
| 44 | + | |
47 | 45 | | |
48 | 46 | | |
49 | 47 | | |
50 | 48 | | |
51 | 49 | | |
52 | 50 | | |
53 | 51 | | |
54 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | | - | |
| 61 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
25 | 33 | | |
26 | 34 | | |
27 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
12 | 17 | | |
13 | 18 | | |
14 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
0 commit comments