2014-01-06 08:33:58 -08:00
'use strict' ;
2014-01-31 09:20:56 -08:00
var path = require ( 'path' ) ,
2014-04-17 05:32:49 -07:00
fs = require ( 'fs' ) ,
2014-01-31 10:00:48 -08:00
rootPath = path . normalize ( _ _dirname + '/..' ) ,
2014-02-11 11:30:58 -08:00
env ,
2014-02-13 08:16:41 -08:00
db ,
port ,
b _port ,
p2p _port ;
2014-04-17 05:32:49 -07:00
function getUserHome ( ) {
return process . env [ ( process . platform == 'win32' ) ? 'USERPROFILE' : 'HOME' ] ;
}
2014-04-17 05:46:19 -07:00
var home = process . env . INSIGHT _DB || ( getUserHome ( ) + '/.insight' ) ;
2014-04-17 05:32:49 -07:00
2014-02-13 08:16:41 -08:00
if ( process . env . INSIGHT _NETWORK === 'livenet' ) {
env = 'livenet' ;
2014-04-17 05:32:49 -07:00
db = home ;
2014-02-13 08:20:19 -08:00
port = '3000' ;
2014-02-13 08:16:41 -08:00
b _port = '8332' ;
p2p _port = '8333' ;
}
else {
env = 'testnet' ;
2014-04-17 05:32:49 -07:00
db = home + '/testnet' ;
2014-02-26 07:05:30 -08:00
port = '3001' ;
b _port = '18332' ;
2014-02-13 08:16:41 -08:00
p2p _port = '18333' ;
}
2014-01-31 10:00:48 -08:00
2014-05-13 10:02:19 -07:00
2014-01-31 10:00:48 -08:00
switch ( process . env . NODE _ENV ) {
case 'production' :
2014-02-13 08:16:41 -08:00
env += '' ;
2014-02-11 11:30:58 -08:00
break ;
2014-01-31 10:00:48 -08:00
case 'test' :
2014-02-13 08:16:41 -08:00
env += ' - test environment' ;
2014-02-11 11:30:58 -08:00
break ;
2014-01-31 10:00:48 -08:00
default :
2014-02-13 08:16:41 -08:00
env += ' - development' ;
2014-02-11 11:30:58 -08:00
break ;
2014-01-31 10:00:48 -08:00
}
2014-02-11 11:30:58 -08:00
2014-02-25 06:10:00 -08:00
var network = process . env . INSIGHT _NETWORK || 'testnet' ;
2014-02-11 13:18:01 -08:00
var dataDir = process . env . BITCOIND _DATADIR ;
var isWin = /^win/ . test ( process . platform ) ;
var isMac = /^darwin/ . test ( process . platform ) ;
var isLinux = /^linux/ . test ( process . platform ) ;
if ( ! dataDir ) {
if ( isWin ) dataDir = '%APPDATA%\\Bitcoin\\' ;
if ( isMac ) dataDir = process . env . HOME + '/Library/Application Support/Bitcoin/' ;
if ( isLinux ) dataDir = process . env . HOME + '/.bitcoin/' ;
}
2014-02-25 06:10:00 -08:00
dataDir += network === 'testnet' ? 'testnet3' : '' ;
2014-02-11 13:18:01 -08:00
2014-04-17 05:32:49 -07:00
if ( ! fs . existsSync ( db ) ) {
console . log ( '## ERROR ##\n\tDB Directory "%s" not found. \n\tCreate it, move your old DB there or set the INSIGHT_DB environment variable.\n\tNOTE: In older insight-api versions, db was stored at <insight-root>/db' , db ) ;
process . exit ( - 1 ) ;
}
2014-01-31 09:20:56 -08:00
module . exports = {
root : rootPath ,
2014-02-26 11:27:22 -08:00
publicPath : process . env . INSIGHT _PUBLIC _PATH || false ,
2014-01-31 10:00:48 -08:00
appName : 'Insight ' + env ,
2014-02-24 20:44:19 -08:00
apiPrefix : '/api' ,
2014-02-11 11:30:58 -08:00
port : port ,
leveldb : db ,
2014-01-31 09:20:56 -08:00
bitcoind : {
protocol : process . env . BITCOIND _PROTO || 'http' ,
user : process . env . BITCOIND _USER || 'user' ,
pass : process . env . BITCOIND _PASS || 'pass' ,
host : process . env . BITCOIND _HOST || '127.0.0.1' ,
2014-02-25 14:07:05 -08:00
port : process . env . BITCOIND _PORT || b _port ,
p2pPort : process . env . BITCOIND _P2P _PORT || p2p _port ,
2014-02-11 13:18:01 -08:00
dataDir : dataDir ,
2014-01-31 09:20:56 -08:00
// DO NOT CHANGE THIS!
disableAgent : true
} ,
2014-02-25 06:10:00 -08:00
network : network ,
2014-01-31 09:20:56 -08:00
disableP2pSync : false ,
disableHistoricSync : false ,
2014-02-26 11:27:22 -08:00
poolMatchFile : rootPath + '/etc/minersPoolStrings.json' ,
2014-02-05 10:59:44 -08:00
// Time to refresh the currency rate. In minutes
2014-02-26 07:05:30 -08:00
currencyRefresh : 10 ,
keys : {
2014-02-26 11:27:22 -08:00
segmentio : process . env . INSIGHT _SEGMENTIO _KEY
}
2014-01-31 09:20:56 -08:00
} ;