Book Image

MEAN Cookbook

By : Nicholas McClay
Book Image

MEAN Cookbook

By: Nicholas McClay

Overview of this book

The MEAN Stack is a framework for web application development using JavaScript-based technologies; MongoDB, Express, Angular, and Node.js. If you want to expand your understanding of using JavaScript to produce a fully functional standalone web application, including the web server, user interface, and database, then this book can help guide you through that transition. This book begins by configuring the frontend of the MEAN stack web application using the Angular JavaScript framework. We then implement common user interface enhancements before moving on to configuring the server layer of our MEAN stack web application using Express for our backend APIs. You will learn to configure the database layer of your MEAN stack web application using MongoDB and the Mongoose framework, including modeling relationships between documents. You will explore advanced topics such as optimizing your web application using WebPack as well as the use of automated testing with the Mocha and Chai frameworks. By the end of the book, you should have acquired a level of proficiency that allows you to confidently build a full production-ready and scalable MEAN stack application.
Table of Contents (13 chapters)

What this book covers

Chapter 1, Working with Angular 4, begins by exploring the frontend layer of our MEAN stack using Angular 4. We'll cover the basics of working with Angular and scaffold out a new application using Angular-CLI. The reader will learn to use Angular-CLI to create components and modules as well as serve the development build of an application to a web browser.

Chapter 2, Enhancing Your User Interface, covers using frontend frameworks such as Sass, Bootstrap, and Font-Awesome. This chapter explores how to add some style to our Angular web application. We'll also look at advanced topics such as component styles and working with Bootstrap components inside an Angular application.

Chapter 3, Working with Data, explains that our Angular application's relationship with data is key to leveraging it in our MEAN stack application. Here, we'll review the basic mechanisms behind data binding inputs and forms within Angular to models. This includes more advanced topics such as working with data services and validating it, using promises to create asynchronous services, retrieving and querying API data, and handling API errors and invalid responses.

Chapter 4, Using Express Web Server, turns our attention to the backend of our MEAN stack web application; we will explore setting up an Express web server using Node.js. This chapter covers the basics of serving assets and routing with Express as well as an exploration of securing an Express web server in production environments.

Chapter 5, REST APIs and Authentication, continues with building our Express web server; we'll build our own APIs for serving resources to our frontend Angular application. The reader will learn how to structure APIs using JSON API to send data and errors to our client. We'll also explore the intricacies of implementing authentication and authorization in our application.

Chapter 6, Cloud Service Integrations, covers the various types of cloud service integrations for our backend Express webserver, including handling images with Cloudinary and implementing a payment gateway using Stripe. We'll also implement a credit card payment user interface with Angular using Stripe.

Chapter 7, MongoDB and Mongoose, explains how to use MongoDB as our database for our Express application. This chapter will cover configuring MongoDB as well as using Mongoose to manage models between an Express web server and a database.

Chapter 8, Relationships, focuses on structuring relationships between our documents in MongoDB. We'll cover the most common types of document relationships, including validation, virutals, subdocuments, and document population with Mongoose.

Chapter 9, Build Systems and Optimizations, dives deep into using the WebPack build system for both Angular and Express. This chapter discusses advanced optimization strategies to increase the loading speed and performance of our web applications.

Chapter 10, Debugging, explores the myriad of options available for debugging a MEAN stack web application. We'll cover the built-in debugger tools of Node.js as well as configuring IDE debuggers such as JetBrain's WebStorm. The chapter will also cover how to set up production error logging for Angular using the error logging service Sentry.io.

Chapter 11, Automated Testing, concludes the book with a review of the range of testing options within our MEAN stack web application. We'll cover writing unit and integration tests for our Express web application using Mocha and Chai. The reader will also be introduced to how to configure ESLint as a Node.js project linter, and use BrowserSync for cross-browser testing.