@thgh/tunnelmole
Version:
Tunnelmole, an open source ngrok alternative. Instant public URLs for any http/https based application. Available as a command line application or as an NPM dependency for your code. Stable and maintained. Good test coverage. Works behind firewalls
30 lines • 1.18 kB
JavaScript
import tunnelmole from "../tunnelmole.js";
import isNumber from 'is-number';
/**
* Build Options from the command line input, then pass them off to tunnelmole()
*/
export default async function dispatchCommand(arg0, command) {
const options = {};
if (isNumber(arg0)) {
options.port = parseInt(arg0);
}
if (typeof command.args[1] === 'string' && command.args[1].toLowerCase() === 'as' && typeof command.args[2] === 'string') {
options.domain = command.args[2];
}
else if (typeof command.args[1] === 'string' && command.args[1] === "AS" && typeof command.args[2] !== 'string') {
console.info("Please enter the domain you want to expose e.g. foo.tunnelmole.net");
}
// Set the API key if an API key is passed in
const apiKey = command.setApiKey || undefined;
if (typeof apiKey === 'string') {
options.setApiKey = command.setApiKey;
}
if (options.port || options.setApiKey) {
// We have enough to Launch Tunnelmole
tunnelmole(options);
return;
}
// No actions to dispatch based on arguments. Show help.
command.help();
}
//# sourceMappingURL=dispatch-command.js.map