Express, a framework that sits on top of Node.js’s web server and makes it easier to use Middleware and routing, two features of Express.
Comparing asynchronous code (like Node.js) to synchronous code. Note that asynchronous code can complete much faster, even though we’re never executing your code in parallel. It doesn’t mean to tell that Node.js is the fastest in the world because of its asynchronous capabilities. There is a lot of other programming languages that allows only synchronous. Node.js can squeeze a lot of performance out of one CPU core, but it doesn’t excel with multiple cores because of the node work as single thread programming.
Express’s minimal philosophy
Express is a framework, the developer doesn’t have to follow some rigid structure or standard. Express is flexible, allow developers, the large numbers of other libraries that we integrate into our Express applications.
But this minimalism is a double-edged sword. It’s flexible and your apps are free of unused cruft, but it does very little for you in comparison to other frameworks. This means that you make mistakes, you have to make far more decisions about your application’s architecture, and you have to spend more time hunting for the right third party
The core parts of Express
The Express has just four major features: middleware, routing, sub-applications, and conveniences.
Node.js gives you one request handler function to work with. The request comes into your function and the response goes out of your function. In express rather than one monolithic request handler function, you call several request handler functions that each deal with a small chunk of the work. These smaller request handler functions are called middleware functions, or middleware.
Example Middleware can handle tasks from logging requests to sending static files to setting HTTP headers. The first middleware function you might use in an application is a logger— it logs every request that comes into your server. When the logger has finished logging, it will continue on to the next middleware in the chain. This next middleware function might authenticate users. If they’re visiting a forbidden URL, it will respond with a “not authorized” page. If they are allowed to visit it, they can continue to the next function in the chain.
Like middleware, it breaks the one monolithic request handler function into smaller pieces. Unlike middleware, these request handlers are executed conditionally, depending on what URL and HTTP method a client sends.
Express applications can often be pretty small, even fitting in just one file. As the applications get larger, we can break them up into multiple folders and
files. Express is unopinionated about how you scale your app, but it provides one important feature that’s super helpful: sub applications. In Express lingo, these miniapplications
are called routers.
Express is often used to power single-page applications (SPAs). SPAs are very
Express example – we can also find example applications all throughout the Express repository, at https://github.com/strongloop/express/tree/master/examples.
Express hello world example code.