Mastering MEAN Stack: Build full stack applications using MongoDB, Express.js, Angular, and Node.js (English Edition) 9355510527, 9789355510525

A step-by-step guide to building web applications with the MEAN stack Key Features ● Gain a comprehensive unders

194 45 16MB

English Pages 260 Year 2023

Report DMCA / Copyright

DOWNLOAD FILE

Mastering MEAN Stack: Build full stack applications using MongoDB, Express.js, Angular, and Node.js (English Edition)
 9355510527, 9789355510525

Table of contents :
Book title
Inner title
Copyright
Dedicated
About the Author
About the Reviewer
Acknowledgement
Preface
Code Bundle and Coloured Images
Reviews
Table of Contents
Chapter 1: Fundamentals of Full Stack Development and the MEAN Stack
Structure
Objectives
What is full stack development?
Frontend
Backend
Database
Introduction to the MEAN stack
Our sample application
Introduction to Node.js
Introduction to Express.js
Introduction to MongoDB
Introduction to Angular
Introduction to TypeScript and Bootstrap
Introduction to TypeScript
Introduction to Bootstrap
Introduction to Git as a version control system
Interaction between components of the MEAN stack
Introduction to Docker and Kubernetes as deployment tools
Conclusion
Questions
Chapter 2: Architectural Design of Our Sample Applic
ation
Structure
Objectives
What are single-page applications?
Advantages of SPA
Disadvantages of SPA
What are multi-page applications?
Advantages of multi-page applications
Disadvantages of multi-page applications
Single-page v/s multi-page applications
Common MEAN stack architecture
Going with the event-driven approach
Best practices for designing an API
Working with the singleton pattern
Working with the Observer pattern
Designing a flexible architecture
Differences between the architecture of an application in the dev and prod environment
Conclusion
Questions
Chapter 3: Installing the
Components
Structure
Objectives
Installing the Node.js runtime
Installing the Node.js on Windows
Installing the Node.js runtime on macOS
Installing the Node.js runtime on Linux
Creating the project folder
Installing the Angular-CLI
Creating a new Angular project
Installing Angular Material
Verifying that Angular works
Exploring the project structure
Scanning the package: json file
The node_modules folder
Looking at the app folder
Starting an Angular application
Conclusion
Questions
Chapter 4: Creation of the Frontend Using Angular
Structure
Objectives
Understanding the folder structure
Working with components
General component structure of an Angular app
Component structure for our application
Creation of Nav Bar component
Looking at the nav-bar.component.ts
Looking at the nav-bar.component.html
Routing in Angular
Routing module
Few Routing directives
The RouterLink directive
The RouterLinkActive directive
The RouterLinkActiveOptions directive
Implementing the Home page
Looking at the Home component’s TypeScript code
Looking at the Home component’s HTML code
Implementing the Register page
Looking at the Register component’s TypeScript code
Looking at the Register component’s template code
Getting input from the user
Angular Material
Conclusion
Questions
Chapter 5: Addition of Node.js and Ideas for Integration
Structure
Objectives
Understanding an API
Verbs used in building REST APIs
Creating the posts and comments projects
Creating the posts project
Creating the comments project
Testing of the services
Testing the posts service
Testing the comments service
Ideas of connecting with frontend
Conclusion
Questions
Chapter 6: Handling Authorization
Structure
Objectives
Introducing the authentication service
Introduction to Google Cloud
What is a Kubernetes cluster?
Creating a Google Cloud account
Creating a new project
Setting up a Kubernetes cluster
Creating an auth docker build
Creating a .dockerignore file
Creating an authentication deployment
Key elements of a deployment
Key elements of a service
Introducing MongoDB and creating an auth Mongo deployment
Building a user model
Creating index.ts
Creating an Ingress service yaml
Creating an Ingress load balancer
Creating a Kubernetes Secret
Using Skaffold for build automation
Introduction to middleware
Introduction to cookies and JSON web tokens
Password encryption
Error handling using express-validator
Understanding an error-handler
Understanding the current-user
Understanding validate-request.ts
Understanding require-auth.ts
Creating an abstract class for custom error handling
Creating subclasses for validation
Understanding request-validation-err.ts
Understanding database-connection-err.ts
Understanding bad-request-err.ts
Understanding not-found-err.ts
Understanding no-auth-err.ts
Separating the logic for routes
Creating Signup, Signin and CurrentUser routes
Signup route
Signin route
CurrentUser route
Signout route
Testing the application using Postman
Conclusion
Questions
Chapter 7: Creating the Posts Service and NATS Streaming Integration
Structure
Objectives
Introducing the common module
Creating a GIT repository for the common module
Publishing the common module to NPM
Installing required packages in the common module
Making changes to package.json and tsconfig
Making changes to package.json
Changes to tsconfig
Moving the authentication logic in the common module
Installing the common module in the auth folder
Standard process for new services
The Posts service
Creating the Posts folder
Updating the index.ts
Creating the Posts deployment YAML
Creating the Posts Mongo DB deployment YAML
Making changes to the Skaffold YAML
Looking at the Auth deployment YAML
Looking at the Auth index.ts
Creating the Posts service
Creating a new Post
Updating an existing Post
Displaying all Posts
Displaying a specific Post
Creation of the nats-wrapper class
Creation of the Posts model
Introduction to the NATS streaming server
Creating the NATS deployment file
Creating a basic publisher and listener ts files
The Test Publisher
The Test Listener
Understanding the BaseListener and PostCreatedListener
The base-listener class
The post-created-listener class
Understanding the BasePublisher, PostCreatedPublisher and PostUpdatedPublisher
The base-publisher class
The post-created-publisher class
The post-updated-publisher class
Understanding the PostCreatedEvent and the PostUpdatedEvent
The PostCreatedEvent
Understanding the PostUpdatedEvent
Understanding the subjects enum
Updating the common module
Testing the publisher and listener
Testing out the Posts service using Postman
Conclusion
Questions
Chapter 8: Introducing Automated Testing
Introduction
Structure
Objectives
Introducing SuperTest
Setting up automated testing
The index.ts refactor for Auth service
Setup for Auth service
Designing the tests for the Auth Service
Tests for Signup route handler
Tests for Signin route handler
Tests for current user route handler
Tests for Signout route handler
Executing the tests for the Auth Service
The index.ts refactor for the POST service
Setup for the POST service
Designing the tests for the Posts Service
Tests for createPost route handler
Tests for the updatePost route handler
Tests for the indexPost route handler
Tests for the showPosts route handler
Executing the tests for the Posts Service
Conclusion
Questions
Chapter 9: Integrating the Comments
Service
Introduction
Structure
Objectives
Comments service
Nesting comments inside posts
Pros and cons of nesting
What are sub-documents?
Pros and cons of sub-documents
What are references?
Advantages of references
Conclusion
Questions
Chapter 10: Creating the Comments
Service
Structure
Objectives
Comments service
Comments and comments Mongo YAMLs
Changes to ingress yaml
Duplicating the comments model inside the post
Referencing the comments model inside the post model
Editing the routes
The createPost route
The updatePost route
Updates to the te
Changes to the createPost test
Changes to the updatePost test
Executing the tests
Conclusion
Questions
Chapter 11: Implementing the Frontend
Introduction
Structure
Objectives
What is the App component?
Nesting other components inside the app component
What are components and services?
Components
Services
Looking at the register component
Register.component.html file
Register.component.ts file
Auth Service
Running the app
Conclusion
Questions
Index
Back title

Polecaj historie