logo资料库

Full-Stack Web Development with Vue.js and Node.pdf

第1页 / 共358页
第2页 / 共358页
第3页 / 共358页
第4页 / 共358页
第5页 / 共358页
第6页 / 共358页
第7页 / 共358页
第8页 / 共358页
资料共358页,剩余部分请下载后查看
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
WOW! eBook www.wowebook.org
Full-Stack Web Development with Vue.js and Node Build scalable and powerful web apps with modern web stack: MongoDB, Vue, Node.js, and Express Aneeta Sharma BIRMINGHAM - MUMBAI
Full-Stack Web Development with Vue.js and Node Copyright © 2018 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Commissioning Editor: Kunal Chaudhari Acquisition Editor: Nigel Fernandes Content Development Editor: Jason Pereira Technical Editor: Leena Patil Copy Editor: Safis Editing Project Coordinator: Sheejal Shah Proofreader: Safis Editing Indexer: Pratik Shirodkar Graphics: Jason Monteiro Production Coordinator: Shantanu Zagade First published: May 2018 Production reference: 1100518 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78883-114-7 www.packtpub.com WOW! eBook www.wowebook.org
mapt.io Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website. Why subscribe? Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free eBook or video every month Mapt is fully searchable Copy and paste, print, and bookmark content PacktPub.com Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. WOW! eBook www.wowebook.org
Contributors About the author Aneeta Sharma is a software engineer from Kathmandu, Nepal who has been in the tech industry for more than seven years. She started her career as a Web Designer, before becoming a PHP Developer and then a Ruby on Rails engineer. She has been working on both frontend and backend aspects of web application development since she started her career and has been developing web applications professionally since 2009. She likes to explore new technologies and has learned to work with lots of them over the years. Most recently, she has been working with full-stack solutions with Ruby on Rails, along with frontend frameworks such as Vue.js and React.js. I am grateful to Packt Publishing for giving me the opportunity to write this book. I am thankful to the team with whom I worked and everyone who contributed to this book. Thank you all for spending your precious time in ensuring the quality of this book. I loved working with you. I am thankful for my family and friends, as well as my colleagues who supported and encouraged me on this journey. Thank you for being an inspiration. WOW! eBook www.wowebook.org
About the reviewer Anton de Regt is a programmer and blogger with a passion for making life better, faster, and easier. After graduating with a bachelor’s degree in Embedded Systems and Automation, he worked in the Netherlands, China, and the USA as a programmer and database admin. Anton now develops apps for small business owners to help them focus on the things that matter and make their impact bigger. On his tech blog, he writes about a variety of subjects, ranging from cybersecurity and data science, to hackathons and socially responsible programming. Packt is searching for authors like you If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. WOW! eBook www.wowebook.org
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 Introducing npm Installing Node.js from NVM 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 1 6 7 8 8 9 9 10 11 11 11 11 12 12 13 13 13 13 14 14 14 14 15 17 17 18 18 19 19 19 20 20 21 21 22 22 23 23 24 WOW! eBook www.wowebook.org
Table of Contents 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 Why MongoDB? MongoDB queries Creating documents insertOne() insertMany() insert() Retrieving documents Finding all documents Finding documents via filters Updating documents updateOne() updateMany() [ ii ] 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 24 24 25 25 25 25 25 26 26 26 27 28 30 31 32 33 33 35 35 36 37 37 37 42 43 44 44 45 45 49 50 53 54 55 55 56 56 57 58 59 59 60 61 62 62 WOW! eBook www.wowebook.org
分享到:
收藏