Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Express Basics Middleware What is Express Middleware?

what exactly middleware?

i still confuse about middleware, anyone can explain that with the example ?

csr13
csr13
33,250 Points

A bunch of super pretty cool code that takes care of x functionality. For example, say --> the security middleware of Django (Python framework) takes care of the basic security events such as taking measures for events such as Cross Site Scripting, salting and un_salting user credentials, and much more.

You can read the middleware code from any framework that you are interested in. Go to GitHub, find a framework that interests you and search through the contents of their code for middleware. Im sure you can find some great literature.

1 Answer

Kevin Gates
Kevin Gates
15,052 Points

A few official definitions, but MDN seems to be the simplest definition (at the bottom).

From Microsoft

Middleware is software that lies between an operating system and the applications running on it. Essentially functioning as hidden translation layer, middleware enables communication and data management for distributed applications. It’s sometimes called plumbing, as it connects two applications together so data and databases can be easily passed between the “pipe.” Using middleware allows users to perform such requests as submitting forms on a web browser, or allowing the web server to return dynamic web pages based on a user’s profile.

Common middleware examples include database middleware, application server middleware, message-oriented middleware, web middleware, and transaction-processing monitors. Each program typically provides messaging services so that different applications can communicate using messaging frameworks like simple object access protocol (SOAP), web services, representational state transfer (REST), and JavaScript object notation (JSON). While all middleware performs communication functions, the type a company chooses to use will depend on what service is being used and what type of information needs to be communicated. This can include security authentication, transaction management, message queues, applications servers, web servers, and directories. Middleware can also be used for distributed processing with actions occurring in real time rather than sending data back and forth.

Source: https://azure.microsoft.com/en-us/overview/what-is-middleware/


From Redhat

This one has some great images to help you understand.

Analyst and system theorist Nick Gall said, “Middleware is software about software.” Middleware doesn’t offer the functions of a traditional app, it connects software to other software. Middleware is plumbing for your IT infrastructure because middleware allows data to flow from one app to another.

Source: https://www.redhat.com/en/topics/middleware/what-is-middleware


From Mozilla Developer Network(MDN)

Middleware is a (loosly defined) term for any software or service that enables the parts of a system to communicate and manage data. It is the software that handles communication between components and input/output, so developers can focus on the specific purpose of their application.

In server-side web application frameworks, the term is often more specifically used to refer to pre-built software components that can be added to the framework's request/response processing pipeline, to handle tasks such as database access.

Source: https://developer.mozilla.org/en-US/docs/Glossary/Middleware