copay/app.js

49 lines
1.3 KiB
JavaScript
Raw Normal View History

var express = require('express');
var http = require('http');
var app = express();
app.use('/', express.static(__dirname + '/'));
app.get('*', function(req, res) {
return res.sendfile('index.html');
});
app.start = function(port, callback) {
app.set('port', port);
app.use(express.static(__dirname));
2014-07-30 19:14:29 -07:00
if (process.env.USE_HTTPS) {
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
2014-07-30 19:14:29 -07:00
var path = require('path');
var bc = path.dirname(require.resolve('bitcore/package.json'));
// var fs = require('fs');
// var server = require('https').createServer({
// key: fs.readFileSync(bc + '/test/data/x509.key'),
// cert: fs.readFileSync(bc + '/test/data/x509.crt')
// });
2014-07-30 19:14:29 -07:00
var pserver = require(bc + '/examples/PayPro/server.js');
pserver.removeListener('request', pserver.app);
pserver.on('request', function(req, res) {
2014-07-31 14:41:50 -07:00
if (req.url.indexOf('/-/') === 0) {
return pserver.app(req, res);
}
return app(req, res);
2014-07-30 19:14:29 -07:00
});
pserver.listen(port, function() {
2014-07-30 19:14:29 -07:00
callback('https://localhost:' + port);
});
return;
}
app.listen(port, function() {
callback('http://localhost:' + port);
});
};
module.exports = app;
2014-06-06 11:23:40 -07:00
// if we are running in the copay shell context, initialize the shell bindings
if (process.versions && process.versions['atom-shell']) {
require('./shell')(app);
}