What does "mount" mean?

In the node lesson, it says that " A middleware needs to be mounted using the method app.use(path, middlewareFunction)"

What does that even mean? It offers zero explanation, as if you should know it already.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36.

Challenge: Serve Static Assets

Link to the challenge:

I think they mean “mounted” as “attached to”, like you would “mount” a picture on a wall. You can define your middleware function, but it won’t do anything until you attach (mount) it to your server process. Mounting it is taking your middleware and putting it in the chain of processes that your server does.

1 Like

app.use adds your middleware to the middleware stack. On every request from the client, the request and response objects are passed through every middleware before finally reaching your route. The order in which your middlewares are defined is the order in which req and res are passed through them.

Mount is just a word that the lesson creator chose.

As for the path parameter, it means pass the request and response objects through this middleware ONLY IF the request is for the specified endpoint (ex. ‘/profile’ might be the path/endpoint). Otherwise, that middleware won’t be consulted (ie. req and res won’t pass through it for use/modification).

Know what I mean?

1 Like