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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.