WIP
This commit is contained in:
parent
3601a6ec12
commit
0db7fbcde0
3 changed files with 18 additions and 6 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
var ApiResponse = function(config) {
|
var ApiResponse = function(config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.reponse = config.response;
|
this.response = config.response;
|
||||||
this.targetVersion = config.targetVersion;
|
this.targetVersion = config.targetVersion;
|
||||||
this.version = config.version;
|
this.version = config.version;
|
||||||
};
|
};
|
||||||
|
|
@ -16,7 +16,8 @@ module.exports = ApiResponse;
|
||||||
ApiResponse.prototype.respond = function respond(err, res, statusCodeOpt) {
|
ApiResponse.prototype.respond = function respond(err, res, statusCodeOpt) {
|
||||||
var statusCode = statusCodeOpt || 200;
|
var statusCode = statusCodeOpt || 200;
|
||||||
if (err) return this.response.json(statusCode, this._buildErr(err));
|
if (err) return this.response.json(statusCode, this._buildErr(err));
|
||||||
this.response.json(statusCode, this._buildResponse(res));
|
var jsonResponse = this._buildResponse(res);
|
||||||
|
this.response.json(statusCode, jsonResponse);
|
||||||
};
|
};
|
||||||
|
|
||||||
ApiResponse.prototype._buildErr = function _buildErr(err) {
|
ApiResponse.prototype._buildErr = function _buildErr(err) {
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,13 @@ module.exports = function (options) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
routes.init(app, config, trader, authMiddleware);
|
routes.init({
|
||||||
|
app: app,
|
||||||
|
lamassuConfig: config,
|
||||||
|
trader: trader,
|
||||||
|
authMiddleware: authMiddleware,
|
||||||
|
mock: options.mock
|
||||||
|
});
|
||||||
|
|
||||||
return server;
|
return server;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
var _trader;
|
var _trader;
|
||||||
var _lamassuConfig;
|
var _lamassuConfig;
|
||||||
|
var _idVerifier = null;
|
||||||
var logger = require('./logger');
|
var logger = require('./logger');
|
||||||
var ApiResponse = require('./api_response');
|
var ApiResponse = require('./api_response');
|
||||||
|
|
||||||
|
|
@ -102,9 +103,13 @@ var pair = function(req, res) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.init = function(app, config, trader, authMiddleware) {
|
exports.init = function(config) {
|
||||||
_lamassuConfig = config;
|
_lamassuConfig = config.lamassuConfig;
|
||||||
_trader = trader;
|
_trader = config.trader;
|
||||||
|
|
||||||
|
var authMiddleware = config.authMiddleware;
|
||||||
|
var app = config.app;
|
||||||
|
_idVerifier = require('lamassu-idology').factory({mock: config.mock});
|
||||||
|
|
||||||
app.get('/poll', authMiddleware, poll);
|
app.get('/poll', authMiddleware, poll);
|
||||||
app.post('/send', authMiddleware, send);
|
app.post('/send', authMiddleware, send);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue