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
$9.99 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
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
Estimated delivery fee Deliver to Taiwan

Standard delivery 10 - 13 business days

$12.95

Premium delivery 5 - 8 business days

$45.95
(Includes tracking information)

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 Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Taiwan

Standard delivery 10 - 13 business days

$12.95

Premium delivery 5 - 8 business days

$45.95
(Includes tracking information)

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
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

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela