Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 785 Vote(s) - 3.43 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using app.configure in express

#1
I found some code where they set up Express without using `app.configure` and I was wondering, what's the difference between using `app.configure` without an environment specifier and not using it?

In other words, what's the difference between this:

var app = require(express);

app.configure(function(){
app.set('port', process.env.PORT || config.port);
app.use(express.logger('dev')); /* 'default', 'short', 'tiny', 'dev' */
app.use(express.bodyParser());
app.use(express.static(path.join(__dirname, 'site')));
}

and this:

var app = require(express);

app.set('port', process.env.PORT || config.port);
app.use(express.logger('dev')); /* 'default', 'short', 'tiny', 'dev' */
app.use(express.bodyParser());
app.use(express.static(path.join(__dirname, 'site')));

Thanks.
Reply

#2
It is optional and remain for legacy reason, according to the doc.
In your example, the two piece of codes have no difference at all.

[To see links please register here]


**Update 2015:**

@IlanFrumer points out that app.configure is removed in Express 4.x. If you followed some outdated tutorials and wondering why it didn't work, You should remove `app.configure(function(){ ... }`. Like this:


var express = require('express');
var app = express();

app.use(...);
app.use(...);

app.get('/', function (req, res) {
...
});
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through