Browse Source

Added comments

pull/1/head
Muthu Kumar 7 years ago
parent
commit
82021b7ede
  1. 14
      index.js

14
index.js

@ -10,10 +10,11 @@ var validator = require('validator')
// Requiring Actions // Requiring Actions
var createProxyServer = require('./actions/createProxyServer') var createProxyServer = require('./actions/createProxyServer')
// // Using Validator
var isFQDN = validator.isFQDN var isDomain = validator.isFQDN
/* Uncomment in Production!
/*
//Detect Linux or BSD //Detect Linux or BSD
var isLin = /^linux|^bsd/.test(process.platform) var isLin = /^linux|^bsd/.test(process.platform)
@ -37,7 +38,7 @@ program
.command('static <domain> [relativePath] [outPort]') .command('static <domain> [relativePath] [outPort]')
.description('Create a static server at this folder.') .description('Create a static server at this folder.')
.action(function(domain, relativePath="", outPort="") { .action(function(domain, relativePath="", outPort="") {
if(!isFQDN(domain)) console.log('\nDomain is not valid. Please use a valid domain name.') if(!isDomain(domain)) console.log('\nDomain is not valid. Please use a valid domain name.')
// Stuff happens here // Stuff happens here
}) })
@ -47,17 +48,18 @@ program
.action(function(domain, inPort, outPort = "") { .action(function(domain, inPort, outPort = "") {
var validInPort = /^\d+$/.test(inPort) var validInPort = /^\d+$/.test(inPort)
var validOutPort = /^\d+$/.test(outPort) var validOutPort = /^\d+$/.test(outPort)
if(!isFQDN(domain)) { if(!isDomain(domain)) {
console.log('\nDomain is not valid. Please use a valid domain name.') console.log('\nDomain is not valid. Please use a valid domain name.')
return; } return; }
if(!validInPort || !validOutPort) { if(!validInPort || !validOutPort) {
// This part doesn't work yet.
if (!((validInPort > 0 && validInPort <= 65535) && (validOutPort > 0 && validOutPort <= 65535))) { if (!((validInPort > 0 && validInPort <= 65535) && (validOutPort > 0 && validOutPort <= 65535))) {
console.log('\nPort should be a number from 1 and 65535.') console.log('\nPort should be a number from 1 and 65535.')
return; } return; }
console.log('\nPort should be a number.') console.log('\nPort should be a number.')
return; } return; }
else { else {
//createProxyServer(domain, inPort) createProxyServer(domain, inPort)
console.log('Done!') console.log('Done!')
} }
}) })

Loading…
Cancel
Save