Full-Stack Web Development with Vue.js and Node

(singke) #1

2


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 conventions for the application
Folder reorganization to incorporate MVC
View creation for the Express.js application

There are a lot of npm packages out there that can let us create a skeleton for an Express.js


application. One such package is express-generator. This lets us scaffold the whole


application in seconds. It will create all the necessary files and folders in a modular
structure. It generates the file structures in such a way that is very easy to understand. The


only thing that we need to do is to define the template views and the routes.

Free download pdf