Skip to content

Commit

Permalink
add configuration file for app
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyettinger committed Sep 23, 2011
1 parent d852e3d commit 1fb606e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,29 @@ An example NodeJS application which uses an event-stream to push notifications t
Configuration
-------------

Edit stream.js and set your twitter username password to see twitter's stream.
Method 1:

var username = 'twitter_username', //ie: 'chovy'
password = 'twitter_password'; //ie: 'xxxxx'
export TWITTER_USERNAME='your_username';
export TWITTER_PASSWORD='your_password';

Go to last line and change your IP number to whatever IP you are serving from and port number if different than 8080, or you can use 'localhost' to test locally.
Method 2:

}).listen(8080, "192.168.1.1");
...or edit config.js and set your twitter username password.

config.twitter_username = process.env.TWITTER_USERNAME || 'my_username';
config.twitter_password = process.env.TWITTER_PASSWORD || 'my_password';


config.js
---------

Edit config.js and set your port number to listen on and IP address (you can use 'localhost' too).

config.port = 8080;
config.address = '192.168.1.64';

Modules
-------

You may need to install some missing modules with npm. http://npmjs.org/

Expand Down
8 changes: 8 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var config = {};

config.port = 8080;
config.address = '192.168.1.64';
config.twitter_username = process.env.TWITTER_USERNAME || 'my_username';
config.twitter_password = process.env.TWITTER_PASSWORD || 'my_password';

module.exports = config;
9 changes: 5 additions & 4 deletions stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var http = require('http'),
sys = require("sys"),
spawn = require("child_process").spawn,
jsonline = require('json-line-protocol').JsonLineProtocol,
cfg = require('./config');
fs = require("fs");

http.createServer(function (req, res) {
Expand All @@ -12,8 +13,8 @@ http.createServer(function (req, res) {

if ( uri == '/stream' ) {
var jsonTwitter = new jsonline();
var username = 'twitter_username',
password = 'twitter_password';
var username = cfg.twitter_username,
password = cfg.twitter_password;
var options = {
host: 'stream.twitter.com',
port: 80,
Expand Down Expand Up @@ -116,6 +117,6 @@ http.createServer(function (req, res) {
});
});
}
}).listen(8080, "192.168.1.64");
}).listen(cfg.port, cfg.address);

console.log('Server running at http://192.168.1.64:8080/');
console.log('Server running at http://'+cfg.address+':'+cfg.port+'/');

0 comments on commit 1fb606e

Please sign in to comment.