Skip to content
This repository was archived by the owner on Mar 5, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Dependency directory
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules
node_modules
yarn.lock
140 changes: 81 additions & 59 deletions AppConfig.js
Original file line number Diff line number Diff line change
@@ -1,67 +1,89 @@
var path = require('path');
var path = require('path');
var rootPath = path.normalize(__dirname + '/..');
var env = process.env.NODE_ENV || 'development';
var env = process.env.NODE_ENV || 'development';

var config = {
development: {
exchanges: {
coincap: {
name: 'CoinCap',
orgUrl: 'http://coincap.io/',
url: 'https://api.coinmarketcap.com/v1/ticker/dash'
},
worldcoin: {
name: 'WorldCoinIndex',
orgUrl: 'https://www.worldcoinindex.com',
url: 'https://www.worldcoinindex.com/apiservice/json',
apiKey: 'ePSl8tl8dsFhLyReZ6aIwCQNw'
}
},
budgets: {
dashwhale: {
name: 'DashWhale',
url: 'https://www.dashwhale.org/api/v1/budget'
}
},
masternodes: {
node40: {
name: 'Node40',
apiKey: '8e4ec80a6394db3411b8af9afa3b5156d36fd18102f1278fef59a3e40d9bf6af',
apiKeyHeader: 'X-Api-Key',
historyUrl: 'https://node40.com/monitor/api/masterNode/history',
statsUrl: 'https://node40.com/monitor/api/masterNode/stats'
}
},
chain: {
insight: {
name: 'Insight',
url: 'https://insight.dash.siampm.com/api/blocks',
maxBlocks: 10
}
},
root: rootPath,
app: {
name: 'dash.org-api'
},
port: process.env.PORT || 9090,
logLevel: 'DEBUG' // EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG
},
development: {
exchanges: {
coincap: {
name: 'CoinCap',
orgUrl: 'http://coincap.io/',
url: 'https://api.coinmarketcap.com/v1/ticker/dash'
},
worldcoin: {
name: 'WorldCoinIndex',
orgUrl: 'https://www.worldcoinindex.com',
url: 'https://www.worldcoinindex.com/apiservice/json',
apiKey: 'ePSl8tl8dsFhLyReZ6aIwCQNw'
}
},
budgets: {
dashwhale: {
name: 'DashWhale',
url: 'https://www.dashwhale.org/api/v1/budget'
}
},
masternodes: {
node40: {
name: 'Node40',
apiKey: '8e4ec80a6394db3411b8af9afa3b5156d36fd18102f1278fef59a3e40d9bf6af',
apiKeyHeader: 'X-Api-Key',
historyUrl: 'https://node40.com/monitor/api/masterNode/history',
statsUrl: 'https://node40.com/monitor/api/masterNode/stats'
}
},
chain: {
insight: {
name: 'Insight',
url: 'https://insight.dash.siampm.com/api/blocks',
maxBlocks: 10
}
},
root: rootPath,
app: {
name: 'dash.org-api'
},
email: {
contactEmailAddress: "contact@dash.org",
transportConfig : {
port: 2525,
host: "localhost",
secure: false,
auth: {
user: "localWebUser",
pass: "asdfg"
}
}
},
port: process.env.PORT || 8080,
logLevel: 'DEBUG' // EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG
},

test: {
root: rootPath,
app: {
name: 'dash.org-api'
},
port: process.env.PORT || 9090
},
test: {
root: rootPath,
app: {
name: 'dash.org-api'
},
port: process.env.PORT || 9090
},

production: {
root: rootPath,
app: {
name: 'dash.org-api'
},
port: process.env.PORT || 9090
}
production: {
root: rootPath,
app: {
name: 'dash.org-api'
},
port: process.env.PORT || 9090,
email: {
contactEmailAddress: "contact@dash.org",
transportConfig : {
service: "Gmail",
auth: {
user: "",
pass: ""
}
}
},
}
};

module.exports = config[env];
14 changes: 14 additions & 0 deletions Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ var AppConfig = require('./AppConfig');
var Cache = require('./service/CacheRepository');
var Masternode = require('./service/MasternodeService');
var Blockchain = require('./service/BlockchainService');
var Email = require('./service/EmailService');
var bodyParser = require('body-parser')

app.use( bodyParser.json() ); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));

// Add headers
app.use(function (req, res, next) {
Expand Down Expand Up @@ -87,6 +94,13 @@ app.get('/exchange', function(req,res){

});

app.post('/send-contact-email', function(req,res){

var results = Email.sendMail(AppConfig.email.contactEmailAddress,req.body.subject, req.body.message);
res.send(results);

});

global.cacheConnection = Cache.connect();

var server = app.listen(AppConfig.port, function () {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
"dependencies": {
"async": "^2.0.0",
"aws-sdk": "^2.4.7",
"body-parser": "^1.16.0",
"express": "^4.13.3",
"log": "^1.4.0",
"memcached": "^2.2.2",
"nodemailer": "^3.0.2",
"request": "^2.60.0"
}
}
33 changes: 33 additions & 0 deletions service/EmailService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Created by cwilliams on 2/9/17.
*/
var nodemailer = require("nodemailer");
var AppConfig = require("../AppConfig");

var transport = AppConfig.email.transportConfig;
console.log('transport: ', transport);
var smtpTransport = nodemailer.createTransport(transport);

function sendMail(to, subject, text) {
var mailOptions = {
to: to,
subject: subject,
text: text
};

console.log(mailOptions);
smtpTransport.sendMail(mailOptions, function (error, response) {
if (error) {
console.log(error);
res.end("error");
} else {
console.log("Message sent: " + response.message);
res.end("sent");
}
});
}


module.exports = {
sendMail: sendMail
};