Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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
$27.98 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781788831147
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.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
$199.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
$279.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 $ 146.97
Vue.js 2 Design Patterns and Best Practices
$48.99
Full-Stack Web Development with Vue.js and Node
$48.99
Full-Stack React Projects
$48.99
Total $ 146.97 Stars icon

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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.