Hour 23. Creating Middleware with Connect

What You’ll Learn in This Hour:

• What Middleware is

• How you can use Middleware with Connect and Express

• What you can use Middleware for in Connect and Express applications

• What Middleware can offer developers

What Is Middleware?

In the context of Node.js, Middleware is a way to filter a request and response in your application by adding a thin layer between the client and your application logic (see Figure 23.1). It provides a simple way to separate concerns within your application and can lead to more maintainable code, a better security model, and code reuse across projects. The idea is relatively simple, but it offers a great deal of power and flexibility to developers.

Figure 23.1. How Middleware ...

Get Sams Teach Yourself Node.js in 24 Hours now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.