Reputation: 12220
I am a newbie in NodeJS, what to do with the below setting which is given in the Express documentation?
app.configure('production', function(){
app.set('db uri', 'n.n.n.n/prod');
});
Should I just copy and paste or should I need to change the 'db.uri' and 'n.n.n.n' ?
Upvotes: 0
Views: 3323
Reputation: 26690
The idea is that you will set different values for production vs development. In this case the call to app.set() has two parameters key and value. It's up to you to define what keys and their corresponding values make sense for you application.
You might have something like this:
app.configure('production', function(){
app.set('db uri', 'bigdbserver/invoiceDB');
app.set('log level', 'warningsOnly');
});
app.configure('development', function(){
app.set('db uri', 'mylocalbox/invoiceDB');
app.set('log level', 'verbose');
});
updated: Added per Herman Junge's suggestion:
Per the Express documentation, app.configure will match to your NODE_ENV variable. This, you can set it up both ways, in the command line or inside your app:
Command Line
$ NODE_ENV=development node app.js
Inside my app
process.env.NODE_ENV = 'development';
Upvotes: 4
Reputation: 6522
Take a look at the express documentation. It has a great example as to how the app.configure function works. It is syntactic sugar for checking the NODE_ENV environment variable.
Upvotes: 2
Reputation: 6282
They are you application settings, production are the settings you want to use when rolling out your application to a live server, you can also create a app.configure for development. These should be things like database connection strings, loggers, the things that differ across your development environments.
Quick google search will bring about a few things, for example how someone wants to use it:
HTH
Upvotes: 4