|
|
@ -14,7 +14,9 @@ log.disableColor(); |
|
|
|
log.debug = log.verbose; |
|
|
|
log.level = 'debug'; |
|
|
|
|
|
|
|
var ExpressApp = function() {}; |
|
|
|
var ExpressApp = function() { |
|
|
|
this.app = express(); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* start |
|
|
@ -24,11 +26,10 @@ var ExpressApp = function() {}; |
|
|
|
* @param opts.disableLogs |
|
|
|
* @param {Callback} cb |
|
|
|
*/ |
|
|
|
ExpressApp.start = function(opts, cb) { |
|
|
|
ExpressApp.prototype.start = function(opts, cb) { |
|
|
|
opts = opts || {}; |
|
|
|
|
|
|
|
var app = express(); |
|
|
|
app.use(function(req, res, next) { |
|
|
|
this.app.use(function(req, res, next) { |
|
|
|
res.setHeader('Access-Control-Allow-Origin', '*'); |
|
|
|
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, DELETE'); |
|
|
|
res.setHeader('Access-Control-Allow-Headers', 'x-signature,x-identity,X-Requested-With,Content-Type,Authorization'); |
|
|
@ -42,12 +43,12 @@ ExpressApp.start = function(opts, cb) { |
|
|
|
} |
|
|
|
next(); |
|
|
|
} |
|
|
|
app.use(allowCORS); |
|
|
|
app.enable('trust proxy'); |
|
|
|
this.app.use(allowCORS); |
|
|
|
this.app.enable('trust proxy'); |
|
|
|
|
|
|
|
var POST_LIMIT = 1024 * 100 /* Max POST 100 kb */ ; |
|
|
|
|
|
|
|
app.use(bodyParser.json({ |
|
|
|
this.app.use(bodyParser.json({ |
|
|
|
limit: POST_LIMIT |
|
|
|
})); |
|
|
|
|
|
|
@ -58,7 +59,7 @@ ExpressApp.start = function(opts, cb) { |
|
|
|
//var accessLogStream = fs.createWriteStream(__dirname + '/access.log', {flags: 'a'})
|
|
|
|
//app.use(morgan('combined', {stream: accessLogStream}))
|
|
|
|
// app.use(require('morgan')('dev'));
|
|
|
|
app.use(require('morgan')(':remote-addr :date[iso] ":method :url" :status :res[content-length] :response-time ":user-agent" ')); |
|
|
|
this.app.use(require('morgan')(':remote-addr :date[iso] ":method :url" :status :res[content-length] :response-time ":user-agent" ')); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -315,11 +316,9 @@ ExpressApp.start = function(opts, cb) { |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
app.use(opts.basePath || '/bws/api', router); |
|
|
|
this.app.use(opts.basePath || '/bws/api', router); |
|
|
|
|
|
|
|
WalletService.initialize(opts, function(err) { |
|
|
|
return cb(err,app); |
|
|
|
}); |
|
|
|
WalletService.initialize(opts, cb); |
|
|
|
}; |
|
|
|
|
|
|
|
module.exports = ExpressApp; |
|
|
|