Miroslav Trninic
Miroslav Trninic

Reputation: 3455

what belongs to express.js middleware layer

I do not know what belongs to the middleware layer in express.js. Can all the methods that are not part of the HTTP protocol methods, ( but belongs to namespace of main app ) be considered middleware? For example app.set,app.param...

Thanks for answer

Upvotes: 0

Views: 212

Answers (1)

Peter Lyons
Peter Lyons

Reputation: 146054

The middleware layer is a list of functions express will execute to process incoming requests. It is defined by your calls to app.use.

app.set, app.param, etc have nothing to do with the middleware stack directly and are thus unrelated.

The one bit of deep magic is that express has a piece of middleware called the router which it normally adds to the middleware chain automatically the first time you call any of the HTTP method "verb" methods: app.(get|post|put|head|del|patch|etc), express will see if the router has been added to the middleware stack and insert it if needed.

Upvotes: 1

Related Questions