Created
October 6, 2012 18:39
-
-
Save rafb43/3845746 to your computer and use it in GitHub Desktop.
Mongo config for local + heroku
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var connStr = process.env.MONGOHQ_URL; | |
| var config = { | |
| name: 'database_name', | |
| host: 'localhost', | |
| port: 27017, | |
| opts: {auto_reconnect: true} | |
| }; | |
| if (connStr) { | |
| var url = require('url'); | |
| var conn = url.parse(connStr); | |
| config.name = conn.path.replace('/', ''); | |
| config.host = conn.host.replace(/:.*/, ''); | |
| config.port = parseInt(conn.port); | |
| config.user = conn.auth.replace(/:.*/, ''); | |
| config.pass = conn.auth.replace(/.*:/, ''); | |
| } | |
| module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment