How to structure app.configure in Express

I use Express 3.0 alpha to build the application, but got a little confused with the configuration of the application

app.configure -> app.set "views", __dirname + "/views" app.set "view engine", "jade" app.use express.bodyParser() app.use express.methodOverride() app.configure "development", -> app.use express.logger("dev") app.configure "production", -> app.use express.logger() 
  • Is the first app.configure, -> required app.configure, -> ? I have been browsing other people's apps and it seems I am not using it.

  • How does ordering work for app.configure, -> ? It seems correct to put specific environments (development and production) after the first app.configure, -> , as I saw in other applications, but it does not work with my application (that is, the log does not print anything in my console at all).

Thanks in advance!

+7
source share
1 answer

They are simply executed sequentially. The first will be called for all environments, so it doesn’t matter if it completes configure() ; it looks better. But if you look at the Express Release lineup, they are likely to disappear in the future, as they are effectively simply glorified if statements.

+8
source

All Articles