Cover
Title Page
Copyright and Credits
PacktPub.com
Contributors
Table of Contents
Preface
Chapter 1: Introducing MEVN
Evolution of the technology stack in JavaScript
Introducing MEVN
Installing Node.js
Installing Node.js on macOS
Installing Node.js using the installer
Installing Node.js using the bash
Installing Node.js on Linux
Installing Node.js from the default distribution
Installing Node.js from NodeSource
Installing Node.js on Windows
Introducing NVM
Installing Node.js from NVM
Introducing npm
Module
Package
Installing npm
Using npm
Installing an npm package locally
Installing an npm package globally
Introducing package.json
Creating a package.json file
Installing MongoDB
The benefits of MongoDB compared to Relational Database Management Systems (RDBMS)
Installing MongoDB on macOS
Installing MongoDB by downloading
Installing MongoDB via Homebrew
Installing MongoDB on Linux
Installing MongoDB using apt-get
Installing MongoDB using tarball
Installing MongoDB on Windows
Using MongoDB
Creating or using a MongoDB database
Creating documents
Fetching documents
Fetching all documents
Fetching a specific document
Updating documents
Deleting documents
Deleting documents that match a given criteria
Deleting a single document that matches the given criteria
Deleting all records
Introducing Git
Installing Git on Windows
Installing Git on Mac
Installing Git on Linux
Introducing GitHub
Why GitHub?
Using GitHub
Setting up a GitHub repository
Summary
Chapter 2: Building an Express Application
Introduction to Node.js
Understanding Node.js
Node.js programming
Node.js modules
Node.js core modules
Custom modules
Introducing Express.js
Installing Express.js
Creating an Express.js application
Express router
Request object
Response object
Introduction to MVC
Why MVC?
Changing the folder structure to incorporate MVC
File naming conventions
Creating view files for the Express.js application
Summary
Chapter 3: Introducing MongoDB
Why MongoDB?
MongoDB queries
Creating documents
insertOne()
insertMany()
insert()
Retrieving documents
Finding all documents
Finding documents via filters
Updating documents
updateOne()
updateMany()
update()
Deleting documents
deleteOne()
deleteMany()
remove()
Introducing Mongoose
Installing Mongoose
Connecting Mongoose to MongoDB
Creating records in Mongoose
Fetching records from Mongoose
Fetching all records
Fetching a specific record
Updating records in Mongoose
findById() and save()
findOneAndUpdate()
findByIdAndUpdate()
Deleting records in Mongoose
remove()
findOneAndRemove
findByIdAndRemove()
Adding validation with Mongoose
Default validations
required()
Type validation
String
Numbers
Custom validations
Summary
Chapter 4: Introducing REST APIs
What is REST?
Introducing REST APIs
Benefits of REST API
HTTP verbs
GET
POST
PUT
DELETE
HTTP status codes
2XX codes
4XX codes
5XX codes
Introducing Postman
Installing Postman
Testing APIs with Postman
Adding a GET endpoint in the users controller
Fetching all users
Fetching a single user
Adding a POST endpoint in the users controller
Adding a PUT endpoint in the users controller
Adding a DELETE endpoint in the users controller
Summary
Chapter 5: Building the Real Application
Introducing Vue.js
Installing Vue.js
Including it in a script tag
Using Content Delivery Network (CDN) links directly
Using Vue.js as an npm package
Introducing vue-cli
Initializing projects with vue-cli
Project folder structure
Building a static application with Vue.js
Redefining the home page
Segregating CSS
Introduction to Vuetify
Redesigning pages with Vuetify
Redesigning the home page
Redesigning the contact page
Understanding Vue.js components
Vue.js directives
v-text
v-on
Data binding
Handling forms with Vue.js
Creating a movies listing page
Creating an Add movie form
Communicating with servers
Adding express to our application
Adding a server file
Adding a Movie model
Adding movies controller
Connecting frontend and backend
Installing axios
Connecting all the pieces
Adding form validations
Adding a flash message
Loading dynamic content on the homepage
API endpoint to fetch all movies
Modifying Home.vue to display dynamic content
Adding a movie profile page
Summary
Chapter 6: Building Authentication with passport.js
Introduction to passport.js
JWT
Installing passport.js
Configuring passport
passport.js strategies
Installing the passport-jwt strategy
Configuring the passport-jwt strategy
Using the JWT strategy
Setting up user registration
Creating a User model
Installing bcryptjs
Adding API endpoint to register a user
Creating a register view page
Adding submit and clear methods in the register form
Introducing axios
Using axios
Setting up the user login
Modifying the User model
Adding an API endpoint to log a user in
Creating a register view page
Adding submit and clear methods to the login form
Authenticating our user in Home.vue
Serving static files for Vue components
Passport's Local Strategy
Installing Passport's Local Strategy
Configuring Passport's Local Strategy
Adding necessary routes for Local Authentication
Installing express-session
Configuring express-session
Configuring emit method
Summary
Chapter 7: Building OAuth Strategies with passport.js
Passport's Facebook Strategy
Installing Passport's Facebook Strategy
Configuring Passport's Facebook Strategy
Creating and setting up a Facebook app
Adding a button to our login page that allows users to log in via Facebook
Adding configurations for Facebook app
Adding necessary routes for Facebook login
Passport's Twitter Strategy
Installing Passport's Twitter Strategy
Configuring Passport's Twitter Strategy
Creating and setting up a Twitter app
Adding a button to our login page that allows users to log in via Twitter
Adding configurations for Twitter App
Adding necessary routes for Twitter login
Passport's Google strategy
Installing Passport's Google strategy
Configuring Passport's Google strategy
Creating and setting up a Google app
Adding a button to our login page that allows users to log in via Google
Adding configurations for Google app
Adding necessary routes for Google login
Passport's LinkedIn strategy
Installing Passport's LinkedIn strategy
Configuring Passport's LinkedIn strategy
Creating and setting up a LinkedIn app
Adding a button to our login page that allows users to log in via LinkedIn
Adding configurations for LinkedIn app
Adding necessary routes for LinkedIn login
Summary
Chapter 8: Introducing Vuex
Traditional multi-web page application
An introduction to SPAs
SPA versus MPA
Pros of using MPAs
Cons of using MPAs
Pros of using SPAs
Cons of using SPAs
An introduction to Vuex
Core concepts of Vuex
Creating a simple Vuex application
Installing Vuex
Setting up Vuex
Creating a store file
State
Getters
mutations
Actions
Installing and using Vuex in a movie application
Defining a store
Modifying Home.vue
Creating an action
Creating a mutation
Creating a getter
Summary
Chapter 9: Testing an MEVN Application
Benefits of writing tests
Introduction to unit tests
Convention for writing unit tests
An introduction to end-to-end test
Convention for writing end-to-end tests
Technologies we will be using
Introducing Mocha
Introducing chai
Introducing sinon
Writing tests for Node.js server
Writing tests for controllers
Writing tests for models
Writing tests for Vue.js components
Writing e2e testing
Installing Nightwatch
Configuring Nightwatch
Summary
Chapter 10
: Going Live
Continuous integration
Workflow for CI
Benefits of CI
Introduction to Travis CI
Setting up Travis in the app
Activating the repository
Specifying the Node.js version
Building the script
Managing the dependencies
Introduction to Heroku
Setting up a Heroku account
Creating a Node.js app
Installing Heroku
Installing Heroku in Windows
Installing Heroku in Linux
Installing Heroku in macOS X
Deploying to Heroku
Heroku error logs
Summary
Other Books You May Enjoy
Index