diff --git a/lib/api_response.js b/lib/api_response.js deleted file mode 100644 index 41f1ef05..00000000 --- a/lib/api_response.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -var ApiResponse = function(res) { - this.response = res; -}; - -ApiResponse.factory = function factory(res) { - return new ApiResponse(res); -}; - -module.exports = ApiResponse; - -ApiResponse.prototype.respond = function respond(err, res, statusCodeOpt) { - var statusCode = statusCodeOpt || 200; - if (err) return this.response.json(statusCode, this._buildErr(err)); - var jsonResponse = this._buildResponse(res); - this.response.json(statusCode, jsonResponse); -}; - -ApiResponse.prototype._buildErr = function _buildErr(err) { - var message = err.message || err; - var name = err.name || null; - - return {err: message, errType: name}; -}; - -ApiResponse.prototype._buildResponse = function _buildResponse(res) { - var fullRes = res; - fullRes = fullRes || {}; - fullRes.err = null; - return fullRes; -}; \ No newline at end of file diff --git a/lib/routes.js b/lib/routes.js index 57ce8e85..5a98113b 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -4,17 +4,12 @@ var _trader; var _lamassuConfig; var _idVerifier = null; var logger = require('./logger'); -var ApiResponse = require('./api_response'); // Make sure these are higher than polling interval // or there will be a lot of errors var STALE_TICKER = 180000; var STALE_BALANCE = 180000; -function prepareApi(req, res) { - return ApiResponse.factory(res); -} - var poll = function(req, res) { var rateRec = _trader.rate(); var balanceRec = _trader.balance; @@ -121,6 +116,6 @@ exports.init = function(config) { }; function getFingerprint(req) { - return req.connection.getPeerCertificate && + return req.connection.getPeerCertificate && req.connection.getPeerCertificate().fingerprint; }