Microservices with Node JS and React

Microservices with Node JS and React

English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 54 Hours | 20.7 GB

Build, deploy, and scale an E-Commerce app using Microservices built with Node, React, Docker and Kubernetes Event-Based Architecture? Covered! Server side rendering with React? Yep. Scalable, production-ready code? Its here! Microservices are the number one solution for building and scaling out apps that are intended to grow. Just one little issue: there are few resources online that delve into the most complex and nasty issues around them! I built this course to fix that. This course tackles every major issues around microservices head on. From challenges with data replication to confusing unordered event streams, every major challenge of building microservices is covered. Beyond focusing on the basics of microservices, this course is a perfect introduction to the world of full-stack development. You will work all the way from the frontend, assembling a React app using Hooks, to the backend, including database design and deployment strategies. Every step along the way is covered in tremendous detail, with ample diagrams to ensure every step is crystal clear. Many other resources show only the easiest, simplest apps written with microservices. This course does the opposite: we focus on the most challenging aspects of microservices, challenges that you will likely encounter every single day. You will see these difficulties first hand, then solve them with easy-to-understand strategies. How This Course Works This course doesn’t focus on using an off-the-shelf microservices framework. Many exist, but they hide the inner workings and challenges of microservices away from you. Instead, we will be using a minimal number of libraries, and write as much custom code as possible. This will expose you to challenging problems and clever solutions when handling subjects like async events! What Technology You’ll Use Because we are building a full stack application, we will use a variety of technologies. On the frontend, we’ll use React and Next JS to present content to users. Each service is created using Node and Express. Data for each service is held in either a Mongo database or Redis. The entire app is deployed and runs in Docker containers executed in a Kubernetes cluster. Finally, almost all of the code in this course is written with Typescript. This is a scary list of technologies! Not familiar with some of these? No problem! The course is built assuming that you only know the basics of Javascript and Express. No other knowledge is needed – you will learn everything you need to know. What You’ll Be Able to Do By the time you complete this course, you will be able to:
  • Architect a multi-service application
  • Determine whether your app is a good fit for a microservices approach
  • Understand and solve the challenges in async, event-based communication between services
  • Use Docker and Kubernetes to deploy a multi-service app to any cloud provider
  • Organize and enhance the reusability of code in large projects
What You’ll Learn An absolute incredible number of topics are covered in this course. Here is a partial list of what you’ll do:
  • Practice patterns to create scalable microservices for a variety of app domains
  • Build a Server-Side-Rendered React app using Hooks and Next JS
  • Write a custom implementation of an event bus
  • Optionally, run a development environment through a cloud provider
  • Guarantee consistently structured responses from your different API’s
  • See best practices in communication between different services
  • Configure and scale your services using Kubernetes Deployments
  • Document and enforce structure constraints on events shared across microservices
  • Limit access to your APIs using JWT-based authentication
  • And much more!
This is the course I wish I had when I was learning microservices. A course that focuses on the hardest parts, gives clear explanations, and discusses the pros and cons of different design options. Sign up today and join me in mastering microservices!
+ Table of Contents

Fundamental Ideas Around Microservices
1 How to Get Help
2 What Is a Microservice
3 Data in Microservices
4 Big Problems with Data
5 Sync Communication Between Services
6 Event-Based Communication
7 A Crazy Way of Storing Data
8 Pros and Cons of Async Communication

A Mini-Microservices App
9 App Overview
10 Project Setup
11 Posts Service Creation
12 Testing the Posts Service
13 Implementing a Comments Service
14 Quick Comments Test
15 Note on the React App
16 React Project Setup
17 Building Post Submission
18 Handling CORS Errors
19 Fetching and Rendering Posts
20 Creating Comments
21 Displaying Comments
22 Completed React App
23 Request Minimization Strategies
24 An Async Solution
25 Common Questions Around Async Events
26 Event Bus Overview
27 A Basic Event Bus Implementation
28 Emitting Events
29 Emitting Comment Creation Events
30 Receiving Events
31 Creating the Data Query Service
32 Parsing Incoming Events
33 Using the Query Service
34 Adding a Simple Feature
35 Issues with Comment Filtering
36 A Second Approach
37 How to Handle Resource Updates
38 Creating the Moderation Service
39 Adding Comment Moderation
40 Handling Moderation
41 Updating Comment Content
42 A Quick Test
43 Rendering Comments by Status
44 Dealing with Missing Events
45 Implementing Event Sync
47 Event Syncing in Action

Running Services with Docker
48 Deployment Issues
49 Why Docker
50 Why Kubernetes
51 Don’t Know Docker Watch This.
52 Dockerizing the Posts Service
53 Review Some Basic Commands
54 Dockering Other Services

Orchestrating Collections of Services with Kubernetes
55 Installing Kubernetes
57 A Kubernetes Tour
58 Important Kubernetes Terminology
59 Notes on Config Files
60 Creating a Pod
62 Understanding a Pod Spec
63 Common Kubectl Commands
64 A Time-Saving Alias
65 Introducing Deployments
66 Creating a Deployment
67 Common Commands Around Deployments
68 Updating Deployments
69 Preferred Method for Updating Deployments
70 Networking With Services
71 Creating a NodePort Service
72 Accessing NodePort Services
73 Setting Up Cluster IP Services
74 Building a Deployment for the Event Bus
75 Adding ClusterIP Services
76 How to Communicate Between Services
77 Updating Service Addresses
78 Verifying Communication
79 Adding Query, Moderation and Comments
80 Testing Communication
81 Load Balancer Services
82 Load Balancers and Ingress
83 Installing Ingress-Nginx
84 Writing Ingress Config Files
86 Hosts File Tweak
87 Quick Note
88 Deploying the React App
89 Unique Route Paths
90 Final Route Config
91 Introducing Skaffold
92 Skaffold Setup
93 First Time Skaffold Startup
94 A Few Notes on Skaffold

Architecture of Multi-Service Apps
95 Big Ticket Items
96 App Overview
97 Resource Types
98 Service Types
99 Events and Architecture Design
100 Note on Typescript
101 Auth Service Setup
102 Auth K8s Setup
103 Adding Skaffold
104 Note on Code Reloading
105 Ingress-Nginx Setup
106 Hosts File and Security Warning

Leveraging a Cloud Environment for Development
107 Note on Remote Development
108 Remote Dev with Skaffold
109 Google Cloud Initial Setup
110 Kubernetes Cluster Creation
111 Kubectl Contexts
112 Initializing the GCloud SDK
113 Installing the GCloud Context
114 Updating the Skaffold Config
115 More Skaffold Updates
116 Creating a Load Balancer
117 Final Config and Test

Response Normalization Strategies
118 Creating Route Handlers
119 Scaffolding Routes
120 Adding Validation
121 Handling Validation Errors
122 Postman HTTPS Issues
123 Surprising Complexity Around Errors
124 Other Sources of Errors
125 Solution for Error Handling
126 Building an Error Handling Middleware
127 Communicating More Info to the Error Handler
128 Encoding More Information In an Error
129 Subclassing for Custom Errors
130 Determining Error Type
131 Converting Errors to Responses
132 Moving Logic Into Errors
133 Verifying Our Custom Errors
134 Final Error Related Code
135 How to Define New Custom Errors
136 Uh Oh… Async Error Handling

Database Management and Modeling
137 Creating Databases in Kubernetes
139 Connecting to MongoDB
140 Understanding the Signup Flow
141 Getting TypeScript and Mongoose to Cooperate
142 Creating the User Model
143 Type Checking User Properties
144 Adding Static Properties to a Model
145 Defining Extra Document Properties
146 What’s That Angle Bracket For
147 User Creation
148 Proper Error Handling
149 Note on Password Hashing
150 Reminder on Password Hashing
151 Adding Password Hashing
152 Comparing Hashed Password
153 Mongoose Pre-Save Hooks

Authentication Strategies and Options
154 Fundamental Authentication Strategies
155 Huge Issues with Authentication Strategies
156 So Which Option
157 Solving Issues with Option #2
158 Reminder on Cookies vs JWT’s
159 Microservices Auth Requirements
160 Issues with JWT’s and Server Side Rendering
161 Cookies and Encryption
162 Adding Session Support
163 Generating a JWT
164 JWT Signing Keys
165 Securely Storing Secrets with Kubernetes
166 Creating and Accessing Secrets
167 Accessing Env Variables in a Pod
168 Common Response Properties
169 Formatting JSON Properties
170 The Signin Flow
171 Common Request Validation Middleware
172 Sign In Logic
173 Quick Sign In Test
174 Current User Handler
175 Returning the Current User
176 Signing Out
177 Creating a Current User Middleware
178 Augmenting Type Definitions
179 Requiring Auth for Route Access

Testing Isolated Microservices
180 Scope of Testing
181 Testing Goals
182 Testing Architecture
183 Index to App Refactor
184 A Few Dependencies
185 Test Environment Setup
186 Our First Test
187 An Important Note
188 Testing Invalid Input
189 Requiring Unique Emails
190 Changing Node Env During Tests
191 Tests Around Sign In Functionality
192 Testing Sign Out
193 Issues with Cookies During Testing
194 Easy Auth Solution
195 Auth Helper Function
196 Testing Non-Authed Requests

Integrating a Server-Side-Rendered React App
197 Starting the React App
198 Reminder on Server Side Rendering
199 Basics of Next JS
200 Building a Next Image
201 Running Next in Kubernetes
202 Note on File Change Detection
203 Adding Global CSS
204 Adding a Sign Up Form
205 Handling Email and Password Inputs
206 Successful Account Signup
207 Handling Validation Errors
208 The useRequest Hook
209 Using the useRequest Hook
210 An onSuccess Callback
211 Overview on Server Side Rendering
212 Fetching Data During SSR
213 Why the Error
214 Two Possible Solutions
215 Cross Namespace Service Communication
216 When is GetInitialProps Called
217 On the Server or the Browser
220 Specifying the Host
221 Passing Through the Cookies
222 A Reusable API Client
223 Content on the Landing Page
224 The Sign In Form
225 A Reusable Header
226 Moving GetInitialProps
227 Issues with Custom App GetInitialProps
228 Handling Multiple GetInitialProps
229 Passing Props Through
230 Building the Header
231 Conditionally Showing Links
232 Signing Out
233 React App Catchup

Code Sharing and Reuse Between Services
234 Shared Logic Between Services
235 Options for Code Sharing
236 NPM Organizations
237 Publishing NPM Modules
238 Project Setup
239 An Easy Publish Command
240 Relocating Shared Code
241 Updating Import Statements
242 Updating the Common Module

Create-Read-Update-Destroy Server Setup
243 Ticketing Service Overview
244 Project Setup
245 Running the Ticket Service
246 Mongo Connection URI
247 Quick Auth Update
248 Test-First Approach
249 Creating the Router
250 Adding Auth Protection
251 Faking Authentication During Tests
252 Building a Session
253 Testing Request Validation
254 Validating Title and Price
255 Reminder on Mongoose with TypeScript
256 Defining the Ticket Model
257 Creation via Route Handler
258 Testing Show Routes
259 Unexpected Failure!
260 What’s that Error!
261 Better Error Logging
262 Complete Index Route Implementation
263 Ticket Updating
264 Handling Updates
265 Permission Checking
266 Final Update Changes
267 Manual Testing

NATS Streaming Server – An Event Bus Implementation
268 What Now
269 Three Important Items
270 Creating a NATS Streaming Deployment
271 Big Notes on NATS Streaming
272 Building a NATS Test Project
274 Port-Forwarding with Kubectl
275 Publishing Events
276 Listening For Data
277 Accessing Event Data
278 Client ID Generation
279 Queue Groups
280 Manual Ack Mode
281 Client Health Checks
282 Graceful Client Shutdown
283 Core Concurrency Issues
284 Common Questions
285 [Optional] More Possible Concurrency Solutions
286 Solving Concurrency Issues
287 Concurrency Control with the Tickets App
288 Event Redelivery
289 Durable Subscriptions

Connecting to NATS in a Node JS World
290 Reusable NATS Listeners
291 The Listener Abstract Class
292 Extending the Listener
293 Quick Refactor
294 Leveraging TypeScript for Listener Validation
295 Subjects Enum
296 Custom Event Interface
297 Enforcing Listener Subjects
299 Enforcing Data Types
300 Where Does this Get Used
301 Custom Publisher
302 Using the Custom Publisher
303 Awaiting Event Publication
304 Common Event Definitions Summary
305 Updating the Common Module
306 Restarting NATS

Managing a NATS Client
307 Publishing Ticket Creation
308 More on Publishing
309 NATS Client Singleton
310 Remember Mongoose
311 Singleton Implementation
312 Accessing the NATS Client
313 Graceful Shutdown
314 Successful Listen!
315 Ticket Update Publishing
316 Failed Event Publishing
317 Handling Publish Failures
318 Fixing a Few Tests
319 Redirecting Imports
320 Providing a Mock Implementation
321 Test-Suite Wide Mocks
322 Ensuring Mock Invocations
323 NATS Env Variables

Cross-Service Data Replication In Action
324 The Orders Service
325 Scaffolding the Orders Service
326 A Touch More Setup
327 Ingress Routing Rules
328 Scaffolding a Few Route Handlers
329 Subtle Service Coupling
330 Associating Orders and Tickets
331 Order Model Setup
332 The Need for an Enum
333 Creating an Order Status Enum
334 More on Mongoose Refs
335 Defining the Ticket Model
336 Order Creation Logic
337 Finding Reserved Tickets
338 Convenience Document Methods
339 Order Expiration Times
340 Test Suite Setup
341 Asserting Tickets Exist
342 Asserting Reserved Tickets
343 Testing the Success Case
344 Fetching a User’s Orders
345 A Slightly Complicated Test
346 Fetching Individual Orders
347 Does Fetching Work
348 Cancelling an Order
349 Can We Cancel

Understanding Event Flow
350 Orders Service Events
351 Creating the Events
352 Implementing the Publishers
353 Publishing the Order Creation
354 Publishing Order Cancellation
355 Testing Event Publishing

Listening for Events and Handling Concurrency Issues
356 Time for Listeners!
357 Reminder on Listeners
358 Blueprint for Listeners
359 A Few More Reminders
360 Simple onMessage Implementation
361 ID Adjustment
362 Ticket Updated Listener Implementation
363 Initializing the Listeners
364 A Quick Manual Test
365 Clear Concurrency Issues
366 Reminder on Versioning Records
367 Optimistic Concurrency Control
368 Mongoose Update-If-Current
369 Implementing OCC with Mongoose
370 Testing OCC
371 One More Test
372 Who Updates Versions
373 Including Versions in Events
374 Updating Tickets Event Definitions
375 Applying a Version Query
376 Did it Work
377 Abstracted Query Method
378 [Optional] Versioning Without Update-If-Current
379 Testing Listeners
380 A Complete Listener Test
381 Testing the Ack Call
382 Testing the Ticket Updated Listener
383 Success Case Testing
384 Out-Of-Order Events
385 The Next Few Videos
386 Fixing a Few Tests
387 Listeners in the Tickets Service
388 Building the Listener
389 Strategies for Locking a Ticket
390 Reserving a Ticket
391 Setup for Testing Reservation
392 Test Implementation
393 Missing Update Event
394 Private vs Protected Properties
395 Publishing While Listening
396 Mock Function Arguments
397 Order Cancelled Listener
398 A Lightning-Quick Test
399 Don’t Forget to Listen!
400 Rejecting Edits of Reserved Tickets

Worker Services
401 The Expiration Service
402 Expiration Options
403 Initial Setup
404 A Touch of Kubernetes Setup
405 File Sync Setup
406 Listener Creation
407 What’s Bull All About
408 Creating a Queue
409 Queueing a Job on Event Arrival
410 Testing Job Processing
411 Delaying Job Processing
412 Defining the Expiration Complete Event
413 Publishing an Event on Job Processing
414 Handling an Expiration Event
415 Emitting the Order Cancelled Event
416 Testing the Expiration Complete Listener
417 A Touch More Testing
418 Listening for Expiration
419 Don’t Cancel Completed Orders!

Handling Payments
420 The Payments Service
421 Initial Setup
422 Replicated Fields
423 Another Order Model!
424 Update-If-Current
425 Replicating Orders
426 Testing Order Creation
427 Marking an Order as Cancelled
428 Cancelled Testing
429 Starting the Listeners
430 Payments Flow with Stripe
431 Implementing the Create Charge Handler
432 Validating Order Payment
433 Testing Order Validation Before Payment
434 Testing Same-User Validation
435 Stripe Setup
436 Creating a Stripe Secret
437 Creating a Charge with Stripe
438 Manual Testing of Payments
439 Automated Payment Testing
440 Mocked Stripe Client
441 A More Realistic Test Setup
442 Realistic Test Implementation
443 Tying an Order and Charge Together
444 Testing Payment Creation
445 Publishing a Payment Created Event
446 More on Publishing
447 Marking an Order as Complete

Back to the Client
448 A Few More Pages
449 Reminder on Data Fetching with Next
450 Two Quick Fixes
451 Scaffolding a Form
452 Sanitizing Price Input
453 Ticket Creation
454 Listing All Tickets
455 Linking to Wildcard Routes
456 Creating an Order
457 Programmatic Navigation to Wildcard Routes
458 The Expiration Timer
459 Displaying the Expiration
460 Showing a Stripe Payment Form
461 Configuring Stripe
462 Test Credit Card Numbers
463 Paying for an Order
464 Filtering Reserved Tickets
465 Header Links
466 Rendering a List of Orders

CICD
467 Development Workflow
468 Git Repository Approaches
469 Creating a GitHub Action
470 Adding a CI Test Script
471 Running Tests on PR Creation
472 Output of Failing Tests
473 Running Tests in Parallel
474 Verifying a Test Run
475 Selective Test Execution
476 Deployment Options
477 Creating a Hosted Cluster
478 Reminder on Kubernetes Context
479 Reminder on Swapping Contexts
480 The Deployment Plan
481 Building an Image in an Action
482 Testing the Image Build
483 Restarting the Deployment
484 Applying Kubernetes Manifests
485 Prod vs Dev Manifest Files
486 Manual Secret Creation
487 Don’t Forget Ingress-Nginx!
488 Testing Automated Deployment
489 Additional Deploy Files
490 A Successful Deploy!
491 Buying a Domain Name
492 Configuring the Domain Name
493 One Small Fix
494 One More Small Fix
495 I Really Hope This Works
496 Next Steps

[Appendix A] – Basics of Docker
497 Why Use Docker
498 What is Docker
499 Docker for Mac Windows
500 Installing Docker on macOS
501 Installing Docker for Windows Home users
502 Installing Docker for Windows – Professional and Enterprise
503 More Windows Setup – Professional and Enterprise
504 One Last Piece of Windows Setup – Professional and Enterprise
505 Installing Docker on Linux
506 Using the Docker Client
507 But Really… What’s a Container
508 How’s Docker Running on Your Computer
509 Docker Run in Detail
510 Overriding Default Commands
511 Listing Running Containers
512 Container Lifecycle
513 Restarting Stopped Containers
514 Removing Stopped Containers
515 Retrieving Output Logs
516 Stopping Containers
517 Multi-Command Containers
518 Executing Commands in Running Containers
519 The Purpose of the ‘it’ Flag
520 Getting a Command Prompt in a Container
521 Starting with a Shell
522 Container Isolation
523 Creating Docker Images
525 Building a Dockerfile
526 Dockerfile Teardown
527 What’s a Base Image
528 The Build Process in Detail
529 A Brief Recap
530 Rebuilds with Cache
531 Tagging an Image
533 Manual Image Generation with Docker Commit
534 Project Outline
535 Node Server Setup
536 A Few Planned Errors
538 Base Image Issues
539 A Few Missing Files
540 Copying Build Files
541 Reminder for Windows Home Docker Toolbox Students
542 Container Port Forwarding
543 Specifying a Working Directory
544 Unnecessary Rebuilds
545 Minimizing Cache Busting and Rebuilds

[Appendix B] – Basics of Typescript
546 How to Get Help
547 TypeScript Overview
548 Environment Setup
549 A First App
550 Executing Typescript Code
551 One Quick Change
552 Catching Errors with TypeScript
553 Catching More Errors!
554 Do Not Skip – Course Overview
555 Types
556 More on Types
557 Examples of Types
558 Where Do We Use Types
559 Type Annotations and Inference
560 Annotations With Variables
561 Object Literal Annotations
562 Annotations Around Functions
563 Understanding Inference
564 The Any Type
565 Fixing the Any Type
566 Delayed Initialization
567 When Inference Doesn’t Work
568 Annotations Around Functions
569 Inference Around Functions
570 Annotations for Anonymous Functions
571 Void and Never
572 Destructuring with Annotations
573 Annotations Around Objects
574 Arrays in TypeScript
575 Why Typed Arrays
576 Multiple Typees in Arrays
577 When to Use Typed Arrays
578 Tuples in TypeScript
579 Tuples in Action
580 Why Tuples
581 Interfaces
582 Long Type Annotations
583 Fixing Annotations With Interfaces
584 Syntax Around Interfaces
585 Functions in Interfaces
586 Code Reuse with Interfaces
587 General Plan with Interfaces
588 Classes
589 Basic Inheritance
590 Class Method Modifiers
591 Fields in Classes
592 Fields with Inheritance
593 Where to Use Classes
594 App Overview
595 Parcel in Action
596 Project Structure
597 Generating Random Data
598 Type Definition Files
599 Using Type Definition Files
600 Export Statements in TypeScript
601 Defining a Company
602 Adding Google Maps Support
603 Google Maps Integration with TypeScript
604 Exploring Type Definition Files
605 Hiding Functionality
606 Why Use Private Modifiers Here’s Why
607 Adding Markers
608 Duplicate Code
609 One Possible Solution
610 Restricting Access with Interfaces
611 Implicit Type Checks
612 Showing Popup Windows
613 Updating Interface Definitions
614 Optional Implements Clauses
615 App Wrapup