You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have used the same for a couple of projects of mine since it seems really useful way of including the options, but haven't seen it anywhere as a recommended way of doing it. Is this part of some standard/recommended way of creating middleware? Should I edit that guide to reflect this as the recommended way?
The text was updated successfully, but these errors were encountered:
The guide describes the structure of a middleware function as would be passed to express. What you're describing is a middleware factory, the constructor that produces the middleware function.
The factory makes makes the options object scoped to the middleware function, encapsulating its settings in order to make the middleware module more re-usable. For example, a middleware for validating user authentication might take a user type as an option.
I know how to create/use middleware and I'm aware of Writing middleware for use in Express apps, however I am curious about packaging/publishing middleware.
Many of the express middleware seems to be following this convention:
I have used the same for a couple of projects of mine since it seems really useful way of including the options, but haven't seen it anywhere as a recommended way of doing it. Is this part of some standard/recommended way of creating middleware? Should I edit that guide to reflect this as the recommended way?
The text was updated successfully, but these errors were encountered: