Correct order of connect.js middlewares?

Issue

middleware depend on each other, for example methodOverride() checks
req.body.method for the HTTP method override, however bodyParser()
parses the request body and populates req.body. Another example of
this is cookie parsing and session support, we must first use()
cookieParser() followed by session()_.

I wonder how can we know which middleware should be use before another? I wonder if there already exist an ordered list (a list with all middlewares in correct working order) somewhere?

Solution

The list of middleware on connect’s home page is in the correct order, though it doesn’t explicitly call out dependencies.

Answered By – ebohlman

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published