Browse Source

paypro: example - allow more modularity concerning options.

patch-2
Christopher Jeffrey 11 years ago
parent
commit
76092fb1a3
  1. 46
      examples/PayPro/server.js

46
examples/PayPro/server.js

@ -52,8 +52,6 @@ server.setOptions = function(options) {
argv = options; argv = options;
}; };
var isNode = !argv.b && !argv.browser;
var app = express(); var app = express();
/** /**
@ -409,22 +407,30 @@ function error() {
server.on('request', app); server.on('request', app);
server.app = app; server.app = app;
server.port = +argv.p || +argv.port || 8080; server.port = 8080;
server.isNode = true;
if (argv.s) {
server.listen(server.port); setTimeout(function() {
return; server.port = +argv.p || +argv.port || 8080;
} server.isNode = !argv.b && !argv.browser;
// Arguably the same thing as -b or --browser:
if (!module.parent || path.basename(module.parent.filename) === 'index.js') { if (argv.s || argv.server) {
server.listen(server.port, function(addr) { server.listen(server.port, function(addr) {
if (!isNode) return; print('Listening on port %s.', server.port);
var customer = require('./customer');
customer.sendPayment(function(err) {
if (err) return error(err.message);
customer.print('Payment sent successfully.');
}); });
}); return;
} else { }
module.exports = server; if (!module.parent || path.basename(module.parent.filename) === 'index.js') {
} server.listen(server.port, function(addr) {
print('Listening on port %s.', server.port);
if (!server.isNode) return;
var customer = require('./customer');
customer.sendPayment(function(err) {
if (err) return error(err.message);
customer.print('Payment sent successfully.');
});
});
}
}, 1);
module.exports = server;

Loading…
Cancel
Save