From 5b613d0324d5187eb065e7778e89d4f57a5a9881 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 17 Jan 2018 16:48:56 +0000 Subject: [PATCH] config default vars updated --- config/default.js | 4 ++++ config/development.js | 1 + config/index.js | 5 +++++ index.js | 11 +++++++---- package.json | 1 + 5 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 config/default.js create mode 100644 config/development.js create mode 100644 config/index.js diff --git a/config/default.js b/config/default.js new file mode 100644 index 0000000..4e8d52a --- /dev/null +++ b/config/default.js @@ -0,0 +1,4 @@ +module.exports={ +webhook: {URLEndpoint: "/autobounty/fund"}, +bounty: {} +} diff --git a/config/development.js b/config/development.js new file mode 100644 index 0000000..4ba52ba --- /dev/null +++ b/config/development.js @@ -0,0 +1 @@ +module.exports = {} diff --git a/config/index.js b/config/index.js new file mode 100644 index 0000000..d66236f --- /dev/null +++ b/config/index.js @@ -0,0 +1,5 @@ +var _ = require("lodash"); +var defaults = require("./default.js"); +var config = require("./" + (process.env.NODE_ENV || "development") + ".js"); +module.exports = _.merge({}, defaults, config); + diff --git a/index.js b/index.js index caf6979..0402f0a 100644 --- a/index.js +++ b/index.js @@ -8,13 +8,14 @@ * Depends on commiteth version as of 2017-06-10. */ +const config = require('./config'); + const SignerProvider = require('ethjs-provider-signer'); const sign = require('ethjs-signer').sign; const Eth = require('ethjs-query'); const address = process.env.ADDRESS; const name = process.env.NAME; -const webhook_secret = process.env.WEBHOOK_SECRET; const provider = new SignerProvider(process.env.NODE, { signTransaction: (rawTx, cb) => cb(null, sign(rawTx, process.env.KEY)), @@ -33,11 +34,13 @@ app.use(cors()); // Store issue ids and their bounty addresses var issueData = {}; + // Receive a POST request at the address specified by an env. var. -app.post(`/comment/${webhook_secret}`, jsonParser, function(req, res, next){ +app.post(`${config.webhook.URLEndpoint}`, jsonParser, function(req, res, next){ if (!req.body) return res.sendStatus(400); - var commentBody = req.body.comment.body; + return res.sendStatus(200) + /*var commentBody = req.body.comment.body; var issueId = req.body.issue.id; var namePosition = commentBody.search("@" + name); // Store toAddress from commiteth @@ -81,7 +84,7 @@ app.post(`/comment/${webhook_secret}`, jsonParser, function(req, res, next){ } }); }); - } + }*/ }); const port = process.env.PORT || 8181 diff --git a/package.json b/package.json index c1ba9e8..c423e43 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "ethjs-query": "^0.2.4", "ethjs-signer": "^0.1.1", "express": "^4.15.2", + "lodash": "^4.17.4", "web3": "^0.18.2" } }