Skip to content
Browse files

Merge pull request #13 from everzet/feature/config

Feature/config for #12
  • Loading branch information...
2 parents 39e37fc + 4fca0a9 commit 33b7ce106180330b0f343a35844cd40658df2dea @avalanche123 avalanche123 committed Sep 7, 2011
Showing with 43 additions and 47 deletions.
  1. +23 −13 package.json
  2. +4 −4 scripts/poller.js
  3. +16 −30 server.js
View
36 package.json
@@ -1,17 +1,27 @@
{
- "name": "twalks"
- , "version": "0.0.1"
- , "private": true
- , "dependencies": {
- "express": "2.4.3"
+ "name": "twalks"
+ , "version": "0.0.1"
+ , "private": true
+ , "dependencies": {
+ "express": "2.4.3"
, "express-mongoose": "0.0.2"
- , "everyauth": "0.2.18"
- , "ejs": "0.4.3"
- , "mongoose": "2.0.1"
- , "twitter": "0.1.17"
- , "nko": "0.0.9"
- , "embedly": "0.3.4"
- , "mongodb": "0.9.3"
- , "log": "1.2.0"
+ , "everyauth": "0.2.18"
+ , "ejs": "0.4.3"
+ , "mongoose": "2.0.1"
+ , "twitter": "0.1.17"
+ , "nko": "0.0.9"
+ , "embedly": "0.3.4"
+ , "mongodb": "0.9.3"
+ , "log": "1.2.0"
+ }
+ , "config": {
+ "twitter-consumer-key": "DROXwWEJw3tXjU4YJpZLw"
+ , "twitter-consumer-secret": "pwv1Nvlvi3PcQ9fwkojiUd933prElu60Iu8FNAonwcI"
+ , "twitter-access-token": "9881092-BZ6uQiCxPvq4qKhsNu4ptEl2jDXbH9O2HKfVnFDCkA"
+ , "twitter-access-token-secret": "6LNRCRMdg6LE2egHAZLFLcVUWxBDIvgaafG6LKCtec4"
+ , "mongodb-user": "user"
+ , "mongodb-password": "111111"
+ , "mongodb-server": "staff.mongohq.com:10090"
+ , "mongodb-database": "twalks"
}
}
View
8 scripts/poller.js
@@ -1,10 +1,10 @@
var poller = require('../lib/poller')
, Twitter = require('twitter')
, twit = new Twitter({
- consumer_key: 'DROXwWEJw3tXjU4YJpZLw',
- consumer_secret: 'pwv1Nvlvi3PcQ9fwkojiUd933prElu60Iu8FNAonwcI',
- access_token_key: '9881092-BZ6uQiCxPvq4qKhsNu4ptEl2jDXbH9O2HKfVnFDCkA',
- access_token_secret: '6LNRCRMdg6LE2egHAZLFLcVUWxBDIvgaafG6LKCtec4'
+ consumer_key: process.env.npm_package_config_twitter_consumer_key
+ , consumer_secret: process.env.npm_package_config_twitter_consumer_secret
+ , access_token_key: process.env.npm_package_config_twitter_access_token
+ , access_token_secret: process.env.npm_package_config_twitter_access_token_secret
})
, links = require('../lib/links_parser').Parser
, mongodb = require('mongodb')
View
46 server.js
@@ -1,27 +1,4 @@
/**
- * deploy check-in
- */
-require('nko')('UJuIrlX5JM5B0V/g');
-
-/**
- * Params
- */
-var parameters = {
- twitter: {
- consumerKey: 'DROXwWEJw3tXjU4YJpZLw'
- , consumerSecret: 'pwv1Nvlvi3PcQ9fwkojiUd933prElu60Iu8FNAonwcI'
- , accessToken: '9881092-BZ6uQiCxPvq4qKhsNu4ptEl2jDXbH9O2HKfVnFDCkA'
- , accessTokenSecret: '6LNRCRMdg6LE2egHAZLFLcVUWxBDIvgaafG6LKCtec4'
- },
- mongodb: {
- user: 'user'
- , password: '111111'
- , server: 'staff.mongohq.com:10090'
- , database: 'twalks'
- }
-};
-
-/**
* Module dependencies.
*/
var express = require('express')
@@ -37,25 +14,34 @@ var express = require('express')
;
everyauth.twitter
- .consumerKey(parameters.twitter.consumerKey)
- .consumerSecret(parameters.twitter.consumerSecret)
+ .consumerKey(process.env.npm_package_config_twitter_consumer_key)
+ .consumerSecret(process.env.npm_package_config_twitter_consumer_secret)
.findOrCreateUser(function(session, accessToken, accessTokenSecret, userData) {
return users.createUserFromTwitterData(userData);
})
.redirectPath('/')
;
+console.log(process.env);
+console.log('mongodb://'+
+ process.env.npm_package_config_mongodb_user+':'+process.env.npm_package_config_mongodb_password+'@'+
+ process.env.npm_package_config_mongodb_server+'/'+process.env.npm_package_config_mongodb_database);
mongoose
- .connect('mongodb://'+parameters.mongodb.user+':'+parameters.mongodb.password+'@'+parameters.mongodb.server+'/'+parameters.mongodb.database)
+ .connect((process.env.npm_package_config_mongodb_user ?
+ 'mongodb://'+
+ process.env.npm_package_config_mongodb_user+':'+process.env.npm_package_config_mongodb_password+'@'+
+ process.env.npm_package_config_mongodb_server+'/'+process.env.npm_package_config_mongodb_database :
+ 'mongodb://localhost:27017/twalks'
+ ))
;
var app = module.exports = express.createServer()
, twit = new Twitter({
- consumer_key: parameters.twitter.consumerKey,
- consumer_secret: parameters.twitter.consumerSecret,
- access_token_key: parameters.twitter.accessToken,
- access_token_secret: parameters.twitter.accessTokenSecret
+ consumer_key: process.env.npm_package_config_twitter_consumer_key
+ , consumer_secret: process.env.npm_package_config_twitter_consumer_secret
+ , access_token_key: process.env.npm_package_config_twitter_access_token
+ , access_token_secret: process.env.npm_package_config_twitter_access_token_secret
});
var child, jobs = [];

0 comments on commit 33b7ce1

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