Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Full-Stack Web Development with Vue.js and Node
Full-Stack Web Development with Vue.js and Node

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

eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Full-Stack Web Development with Vue.js and Node

Building an Express Application

Express.js is a Node.js web application framework. Express.js makes it easier to use Node.js and leverages its power. In this chapter, we will be creating an application using solely Express.js. Express.js is also a node package. We can use an application generator tool, which lets us create a skeleton of an express app easily, or we can simply create one ourselves from scratch.

In the previous chapter, we learned about what npm is, what a package is, and how to install a package. In this chapter, we will cover the following elements:

  • What Node.js is and what it can do
  • The benefits it adds
  • The basic programming of Node.js
  • Node.js core and custom modules
  • An introduction to Express.js
  • Creation of an application using Express.js
  • Routes in Express.js
  • MVC architecture: what it is and what value it adds when implemented in an application
  • File naming...

Introduction to Node.js

Node.js is a JavaScript runtime build on a JavaScript engine. It is an open source framework used for server-side management. Node.js is lightweight and efficient and runs on various platforms, such as Windows, Linux, and macOS.

Node.js was created by Ryan Dahl in 2009. JavaScript used to be used mostly for client-side scripting, but Node.js enables JavaScript to be used on the server side as well. The invention of Node.js introduced the use of a single programming language in web applications. Node.js brings with it a lot of benefits, some of which are as follows:

  • Event-driven programming: It means changing the state of an object from one to another. Node.js uses event-driven programming, which means it uses a user's interactive actions, such as mouse clicks, and key presses, to change the state of objects.
  • Non-blocking I/O: The non-blocking I/O...

Introducing Express.js

Express.js is a minimalist server-side web framework for Node.js. It is built on top of Node.js to make it easy to manage the Node.js server. The most important strength of Express.js is that it makes the routing very, very easy. The robust API that it provides is very easy to configure. It is easy to receive requests from the frontend and easy to connect to the database. Express.js is also the most popular web framework for Node.js. It uses the Model View Controller (MVC) design pattern, which we will be discussing later on in this chapter.

Installing Express.js

We have already covered how to install node modules via npm. Similarly, we can install Express.js via NPM using this command:

$ npm install...

Introduction to MVC

The MVC model is essential when building applications regardless of any programming languages. The MVC architecture makes it easy to organize our application's structure and separate out logic parts and view parts. We can incorporate this MVC structure at any time, even if we have completed half of our application. The best time to implement it is at the start of any application.

As the name suggests, there are three parts to it:

  • Model: All of the application's business logic resides under these models. These deal with the database. They handle all the logic parts of the application.
  • View: Everything that the browser renders—what users see—is handled by these view files. It deals with whatever we send to the client.
  • Controller: Controllers basically connect these models and views. It is responsible to take the logical calculations...

Creating view files for the Express.js application

We learned about how to create controllers in the last section. In this section, we will talk about how to add and customize view files. If you remember, we have this code in controllers/users.js:

module.exports.controller = (app) => {
// get users page
app.get('/users', (req, res) => {
res.render('index', { title: 'Users' });
})
}

Let's change a line that renders the index file to this:

module.exports.controller = (app) => {
// get users page
app.get('/users', (req, res) => {
res.render('users', { title: 'Users' });
})
}

This means that the controller wants to load the users file, which is in the views folder. Let's go ahead and create a users.pug file in the views folder.

After creating the file, paste in the following code; this is the...

Summary

In this chapter, we learned what Node.js is and what Express.js is. We learned how to create an application using Express.js and learned about the MVC architecture.

In the next chapter, we will talk about MongoDB and its queries. We will also talk about using Mongoose for fast development and Mongoose queries and validations.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Construct modern web applications with Node 10, Express.js, MongoDB, and Vue
  • Leverage the latest web standards to increase code performance, readability, and cross-compatibility
  • Harness the power of the JavaScript ecosystem to effectively run, build, and test your full stack applications

Description

Isomorphic JavaScript was the buzzword of the year 2017, allowing developers to utilize a single language throughout their web development stack and build cost-effective and scalable applications. MEVN is a one such modern web development stack consisting of web applications such as MongoDB, Express.js, Vue.js, and Node.js. Hands-On Full-Stack Web Development with Vue.js 2 and Node.js leverages the harmony of these technologies to help you create full-stack web applications. Starting with the core frameworks, this example-based guide explains all the key concepts of frameworks, how to set them up properly, and how to use popular modules to connect them together and make them work cohesively. You will learn all this with the help of real-world examples. In addition to this, you will be able to scaffold web application architecture, add an authentication layer, and develop the MVC structure to support the development of your application. You'll explore how to create data models for your applications and then write REST APIs by exposing your data model to your application. Solely orientated towards building a full, end-to-end application using the MEVN stack, this book will help you understand how your application development grows.

Who is this book for?

If you are a web or a full-stack JavaScript developer, and have tried your hand at traditional stacks such as LAMP, MEAN or MERN, or wish to explore a new stack with modern web technologies, then this book is for you. Prior knowledge of HTML, CSS, and JavaScript would be an added advantage.

What you will learn

  • Build an application with Express.js
  • Create schemas using Mongoose
  • Develop a single-page application using Vue.js and Express.js
  • Create RESTful APIs using Express.js
  • Add test cases to improve the reliability of the application
  • Learn how to deploy apps on Heroku using GitHub
  • Add authorization using passports

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 14, 2018
Length: 366 pages
Edition : 1st
Language : English
ISBN-13 : 9781788830775
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : May 14, 2018
Length: 366 pages
Edition : 1st
Language : English
ISBN-13 : 9781788830775
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 110.97
Vue.js 2 Design Patterns and Best Practices
€36.99
Full-Stack Web Development with Vue.js and Node
€36.99
Full-Stack React Projects
€36.99
Total 110.97 Stars icon
Banner background image

Table of Contents

11 Chapters
Introducing MEVN Chevron down icon Chevron up icon
Building an Express Application Chevron down icon Chevron up icon
Introducing MongoDB Chevron down icon Chevron up icon
Introducing REST APIs Chevron down icon Chevron up icon
Building the Real Application Chevron down icon Chevron up icon
Building Authentication with passport.js Chevron down icon Chevron up icon
Building OAuth Strategies with passport.js Chevron down icon Chevron up icon
Introducing Vuex Chevron down icon Chevron up icon
Testing an MEVN Application Chevron down icon Chevron up icon
Going Live Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.3
(4 Ratings)
5 star 25%
4 star 0%
3 star 0%
2 star 25%
1 star 50%
Paul Pisces Jan 25, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is an excellent book so far on an updated MEAN -> MEVN stack.I am mostly reading it for the VUE part of the stack but it has been a great recap of Mongo, Node and Express for me.I am up to Chapter 5 so far and I will update my review when I have completed the rest of the book and the examples.I am also reviewing the book because it has received such bad (undeserved?) reviews.My review gives an alternative opinion.This book has so far met MY objectives which are obviously also determined by my experience.I hope it encourages you to give this book a try as it is the only one I have found covering MEVN.
Amazon Verified review Amazon
saiello Oct 16, 2018
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I'm just hitting chapter 5 out of 10 in the book, and I have to say most of it is solid... Until it's not. The end of chapter 3 is completely useless, as there are several pages of code, but there's is no instruction on where to place the code. The book has you create a templated app using MVC, but then they don't tell you if the code they are showing is going in the model or the controller.The book would have gotten 5 out of 5 stars if it wasn't for this huge hole. I'll update the review as I go through more of the book.Updating this review after getting through chapter 5 (Vue.js) Current rating 2 stars, down from 3The Vue.js chapter is pretty horrible. Most of the chapter is simply code that says copy this into your application. There's very little actual education going on here. I feel after reading this chapter, they could have stuck to Node.js and gone into depth about the directory structure of the pre-created Express site. After chapter 5, feel pretty bummed about this book.
Amazon Verified review Amazon
R.Bannai Oct 12, 2018
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
The pack of screen shots and no particularly new information which I defined as something you can hardly find on the Internet. All info is the water-downed version of official documents or worse. Just take a look at official page, which is clearly better since I already knew its contents. If you stuck at your coding, do google, you can find any.I expected this since I knew her as Medium author. For one who is about to purchase, save your money for something valuable.Also I began to doubt this publisher as well.
Amazon Verified review Amazon
Mr. R. Urbanski Sep 19, 2018
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
The book contain a lot of code but it's not described what this code does and what it's needed for. Sometimes it's not even clear at what file this code needs to be added. But the biggest issue I have with the presented examples is that you follow the instructions, just to find out that big part of the code you written to be replaced with a different approach in the next chapter. Why not use a correct approach in the first place? My goal after reading this book is to be able to use the best possible approach and not to waste time on learning some techniques which aren't best practices and will be replaced later on in the book. Also the book contains a lot of incorrect syntax, i.e commas where they shouldn't be, etc. Don't waste your money, find a tutorial on-line it will be more useful. The last nail to the coffin is the code samples on GitHub - you can't simply download a particular file, you need to download the whole chapter where some of the chapters, packed in the countless number of zip files, weights more than a 100 MB. Why not include only the files for each chapter which are modified in this chapter?
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.