Skip to content
Browse files

Converted config to a module. Freeing the dependency on fs and the us…

…e of readFileSync.
  • Loading branch information...
1 parent 67d809c commit fdb97bb1feaf5745c332d09eab3154ec972f0630 Dan Thurman committed Jun 15, 2011
Showing with 20 additions and 8 deletions.
  1. +19 −0 config/config.js
  2. +1 −8 server.js
View
19 config/config.js
@@ -0,0 +1,19 @@
+module.exports = config = {
@isaacs
isaacs added a note Jul 21, 2011

This creates a global "config" object. If that's not your intent, you should do var config = module.exports = { ...

If that is your intent, it'd be better to do module.exports = global.config = { ... so that it's clear that it's not an accident.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ "name" : "Hummingbird",
+
+ "tracking_port" : 8000,
+ "dashboard_port" : 8080,
+
+ "mongo_host" : "localhost",
+ "mongo_port" : 27017,
+
+ "udp_address" : "127.0.0.1",
+ "udp_port" : 8000,
+
+ "enable_dashboard" : true,
+
+ "capistrano" : {
+ "repository" : "git://github.com/mnutt/hummingbird.git",
+ "hummingbird_host" : "hummingbird.your-host.com"
+ }
+}
View
9 server.js
@@ -3,20 +3,13 @@ require.paths.unshift(__dirname);
var http = require('http'),
weekly = require('weekly'),
- fs = require('fs'),
+ config = require('./config/app.json'),
dgram = require('dgram'),
static = require('node-static'),
io = require('socket.io'),
mongo = require('mongodb'),
Hummingbird = require('hummingbird').Hummingbird;
-try {
- var configJSON = fs.readFileSync(__dirname + "/config/app.json");
-} catch(e) {
- console.log("File config/app.json not found. Try: `cp config/app.json.sample config/app.json`");
-}
-var config = JSON.parse(configJSON.toString());
-
db = new mongo.Db('hummingbird', new mongo.Server(config.mongo_host, config.mongo_port, {}), {});
db.addListener("error", function(error) {

0 comments on commit fdb97bb

Please sign in to comment.
Something went wrong with that request. Please try again.