O'Reilly logo

Sams Teach Yourself Node.js in 24 Hours by George Ornbo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required