removed versioning, keeping old style, fixed mocking
This commit is contained in:
parent
f924123bd9
commit
b2e7ca6ad1
3 changed files with 14 additions and 30 deletions
|
|
@ -20,6 +20,8 @@ if (!argv.http) {
|
|||
key: fs.readFileSync(argv.key),
|
||||
cert: fs.readFileSync(argv.cert)
|
||||
};
|
||||
|
||||
options.mock = argv.mock;
|
||||
}
|
||||
|
||||
var server = createServer(options);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
var ApiResponse = function(config) {
|
||||
this.config = config;
|
||||
this.response = config.response;
|
||||
this.targetVersion = config.targetVersion;
|
||||
this.version = config.version;
|
||||
var ApiResponse = function(res) {
|
||||
this.response = res;
|
||||
};
|
||||
|
||||
ApiResponse.factory = function factory(config) {
|
||||
return new ApiResponse(config);
|
||||
ApiResponse.factory = function factory(res) {
|
||||
return new ApiResponse(res);
|
||||
};
|
||||
|
||||
module.exports = ApiResponse;
|
||||
|
|
@ -21,25 +18,15 @@ ApiResponse.prototype.respond = function respond(err, res, statusCodeOpt) {
|
|||
};
|
||||
|
||||
ApiResponse.prototype._buildErr = function _buildErr(err) {
|
||||
// Handle err as either string or error type
|
||||
var message = err.message || err;
|
||||
var name = err.name || null;
|
||||
|
||||
if (this.targetVersion < 1) return {err: message, errType: name};
|
||||
return {err: {
|
||||
name: name,
|
||||
message: message,
|
||||
version: this.version
|
||||
}
|
||||
};
|
||||
return {err: message, errType: name};
|
||||
};
|
||||
|
||||
ApiResponse.prototype._buildResponse = function _buildResponse(res) {
|
||||
if (this.targetVersion < 1) {
|
||||
var fullRes = res;
|
||||
fullRes = fullRes || {};
|
||||
fullRes.err = null;
|
||||
return fullRes;
|
||||
}
|
||||
return {err: null, result: res || null, version: this.version};
|
||||
var fullRes = res;
|
||||
fullRes = fullRes || {};
|
||||
fullRes.err = null;
|
||||
return fullRes;
|
||||
};
|
||||
|
|
@ -11,15 +11,8 @@ var ApiResponse = require('./api_response');
|
|||
var STALE_TICKER = 180000;
|
||||
var STALE_BALANCE = 180000;
|
||||
|
||||
var API_VERSION = 1;
|
||||
|
||||
function prepareApi(req, res) {
|
||||
var targetVersion = parseInt(req.body.version || req.query.version || 0);
|
||||
return ApiResponse.factory({
|
||||
response: res,
|
||||
targetVersion: targetVersion,
|
||||
version: API_VERSION
|
||||
});
|
||||
return ApiResponse.factory(res);
|
||||
}
|
||||
|
||||
var poll = function(req, res) {
|
||||
|
|
@ -112,6 +105,8 @@ exports.init = function(config) {
|
|||
var authMiddleware = config.authMiddleware;
|
||||
var app = config.app;
|
||||
_lamassuConfig.readExchangesConfig(function (err, res) {
|
||||
var idVerifyConfig = res.exchanges.plugins.settings.idology;
|
||||
idVerifyConfig.mock = config.mock;
|
||||
_idVerifier = require('lamassu-idology').factory(res.exchanges.plugins.settings.idology);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue