Skip to content

Latest commit

 

History

History
365 lines (199 loc) · 4.66 KB

02_A_Mini_Microservices_App.md

File metadata and controls

365 lines (199 loc) · 4.66 KB

[Stephen Grider] Microservices with Node JS and React [ENG, 2020]

02. A Mini-Microservices App


Application


Application


02. Project Setup

$ npm install -g nodemon

$ cd app

$ npx create-react-app client

$ cd app

$ mkdir posts
$ cd posts
$ npm init -y

$ npm install --save express cors axios

$ cd app

$ mkdir comments
$ cd comments
$ npm init -y

$ npm install --save express cors axios

03. Posts Service Creation


Application


$ cd posts
$ npm run start

04. Testing the Posts Service


$ curl \
--request POST http://localhost:4000/posts/ \
--header "Content-Type: application/json" \
| python -m json.tool

$ curl \
--request GET http://localhost:4000/posts/ \
--header "Content-Type: application/json" \
| python -m json.tool

05. Implementing a Comments Service


Application


$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

to solve issue:

[nodemon] Internal watch failed: ENOSPC: System limit for number of file watchers reached, watch ***
$ cd comments
$ npm run start

06. Quick Comments Test


$ curl \
--data '{"content":"I am a comment"}' \
--header "Content-Type: application/json" \
--request POST http://localhost:4001/posts/123/comments \
| python -m json.tool

$ curl \
--request GET http://localhost:4001/posts/123/comments \
--header "Content-Type: application/json" \
| python -m json.tool

08. React Project Setup


Application


Application


$ cd client

$ npm install --save axios
$ npm start

09. Building Post Submission


Application


10. Handling CORS Errors


11. Fetching and Rendering Posts


Application


12. Creating Comments


Application


13. Displaying Comments


Application


15. Request Minimization Strategies


16. An Async Solution


17. Common Questions Around Async Events


18. Event Bus Overview


Application


19. A Basic Event Bus Implementation

$ cd app
$ mkdir event-bus
$ cd event-bus

$ npm init -y
$ npm install --save express axios

Application


$ npm run start

20. Emitting Events


21. Emitting Comment Creation Events


22. Receiving Events


Application


23. Creating the Data Query Service


$ cd app
$ mkdir query
$ cd query

$ npm init -y
$ npm install --save express cors axios

$ npm run start

24. Parsing Incoming Events


25. Using the Query Service


26. Adding a Simple Feature


Application


Application


27. Issues with Comment Filtering


Application


28. A Second Approach


Application


29. How to Handle Resource Updates


Application


30. Creating the Moderation Service


$ cd app
$ mkdir moderation
$ cd moderation

$ npm init -y
$ npm install --save express axios

$ npm run start

31. Adding Comment Moderation


32. Handling Moderation


33. Updating Comment Content


34. A Quick Test

Comment with text 'orange' has status 'rejected'.


35. Rendering Comments by Status


Application


36. Dealing with Missing Events


Application


Application


Application


Application


37. Implementing Event Sync


38. Event Syncing in Action



Marley

Any questions in english: Telegram Chat
Любые вопросы на русском: Телеграм чат