by hello_moto · 14y ago · 0 comments
What about switching between PROD, DEV, TEST environment like Rails? I found that feature is great since y'know... those environments will have different settings (I'm guessing the answer to this one is to roll your own kind of thing?)
[1]: https://github.com/visionmedia/expresso
[2]: https://github.com/isaacs/node-tap
Also see my startup that does javascript unit testing in all the browsers: http://www.testling.com
Now about switching environments, see this: http://expressjs.com/guide.html#configuration
And also see bouncy to route between production/development dynamically: https://github.com/substack/bouncy
For instance you might have a .production file
export NODE_ENV="production"
export NODE_PORT="80"
And a .development file export NODE_ENV="development"
export NODE_PORT="3000"
Before you run "node app" just link to your variables with "$ . .production" or "$ sh .production"Again there are many ways to accomplish this same thing but this way is pretty straightforward if you are familiar with linux.
EDIT: To add to the link to configuration pkrumins posted (http://expressjs.com/guide.html#configuration)
process.env will hold all of your environment variables, and express.js will read "NODE_ENV" internally. A combination of the above, and setting up corresponding internal configuration in your node.js app will provide for a very clean setup.