Question

I'm reading through the Express API here: http://expressjs.com/api.html#app.configure

I see that the first argument is optional. What is the point of this? If the first argument is missing, won't the callback ALWAYS be called? If so, what's the point of wrapping it in app.config()?

In other words, is this:

app.configure(function(){
  app.set('title', 'My Application');
})

... the same as this:

  app.set('title', 'My Application');

?

If so, why would I do the first instead of the second?

Était-ce utile?

La solution

Use the second one. I believe that the first one is there for backwards compatibility. It used to be done that way. But you are correct in that there is no point in using configure and I have never used it in my projects.

Edit I found that the docs state that configure is there for legacy reasons. http://expressjs.com/api.html#app.configure

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top