Browse Source

paypro: example - document modular usage of example.

patch-2
Christopher Jeffrey 11 years ago
parent
commit
774dacae8d
  1. 7
      examples/PayPro/README.md
  2. 9
      examples/PayPro/server.js

7
examples/PayPro/README.md

@ -65,3 +65,10 @@ testnet coins, you can pass `--no-tx` on the server command line.
If you don't want the tests to run automatically and simply host the payment If you don't want the tests to run automatically and simply host the payment
server, simply pass `--browser` (`-b`) as mentioned above. server, simply pass `--browser` (`-b`) as mentioned above.
## Using the example in a modular manner
``` js
var server = require('bitcore/examples/PayPro');
server.listen(8080);
```

9
examples/PayPro/server.js

@ -48,8 +48,10 @@ var server = https.createServer({
cert: fs.readFileSync(__dirname + '/../../test/data/x509.crt') cert: fs.readFileSync(__dirname + '/../../test/data/x509.crt')
}); });
server.options = argv;
server.setOptions = function(options) { server.setOptions = function(options) {
argv = options; server.options = argv = options;
}; };
var app = express(); var app = express();
@ -411,10 +413,9 @@ server.port = 8080;
server.isNode = true; server.isNode = true;
setTimeout(function() { setTimeout(function() {
server.port = +argv.p || +argv.port || 8080; server.port = argv.p = argv.port = +argv.p || +argv.port || 8080;
server.isNode = !argv.b && !argv.browser; server.isNode = !argv.b && !argv.browser;
// Arguably the same thing as -b or --browser: if (argv.s || argv.server || argv.l || argv.listen) {
if (argv.s || argv.server) {
server.listen(server.port, function(addr) { server.listen(server.port, function(addr) {
print('Listening on port %s.', server.port); print('Listening on port %s.', server.port);
}); });

Loading…
Cancel
Save