Browse Source

#17 : cmd line option to listen to a particular ip interface of machine.

pull/21/head
oof1lab 7 years ago
parent
commit
8f04c6295e
  1. 19
      README.md
  2. 4
      bin/index.js
  3. 4
      index.js
  4. 4
      lib/util/cmd.helper.js

19
README.md

@ -862,16 +862,17 @@ http://localhost:3000/download?name=fileName
``` ```
Options: Options:
-V, --version output the version number -V, --version Output the version number
-h, --host <n> hostname -> localhost by default -h, --host <n> Hostname of database -> localhost by default
-u, --user <n> username of database -> root by default -u, --user <n> Username of database -> root by default
-p, --password <n> password of database -> empty by default -p, --password <n> Password of database -> empty by default
-d, --database <n> database schema name -d, --database <n> database schema name
-n, --portNumber <n> port number for app -> 3000 by default -r, --ipAddress <n> IP interface of your server / locahost by default
-a, --apiPrefix <n>, api url prefix -> /api/ by default -n, --portNumber <n> Port number for app -> 3000 by default
-s, --storageFolder <n> storage folder -> current working dir by default (available only with local) -a, --apiPrefix <n> Api url prefix -> /api/ by default
-i, --ignoreTables <n> comma separated table names to ignore -s, --storageFolder <n> Storage folder -> current working dir by default (available only with local)
-h, --help output usage information -i, --ignoreTables <n> Comma separated table names to ignore
-h, --help Output usage information
Examples: Examples:

4
bin/index.js

@ -42,9 +42,9 @@ let moreApis = new Xapi(sqlConfig,mysqlPool,app);
moreApis.init((err, results) => { moreApis.init((err, results) => {
app.listen(sqlConfig.portNumber) app.listen(sqlConfig.portNumber,sqlConfig.ipAddress)
var t1 = process.hrtime(t); var t1 = process.hrtime(t);
var t2 = t1[0]+t1[1]/1000000000 var t2 = t1[0]+t1[1]/1000000000;
console.log(' '); console.log(' ');
console.log(" Xmysql took : %d seconds",dataHelp.round(t2,1)); console.log(" Xmysql took : %d seconds",dataHelp.round(t2,1));

4
index.js

@ -43,8 +43,8 @@ let moreApis = new Xapi(sqlConfig,mysqlPool,app);
moreApis.init((err, results) => { moreApis.init((err, results) => {
app.listen(sqlConfig.portNumber) app.listen(sqlConfig.portNumber,sqlConfig.ipAddress)
var t1 = process.hrtime(t); var t1 = process.hrtime(t)
var t2 = t1[0]+t1[1]/1000000000 var t2 = t1[0]+t1[1]/1000000000

4
lib/util/cmd.helper.js

@ -12,10 +12,11 @@ program.on('--help', () => {
program program
.version('0.4.1') .version('0.4.1')
.option('-h, --host <n>', 'hostname / localhost by default') .option('-h, --host <n>', 'hostname of database / localhost by default')
.option('-u, --user <n>', 'username of database / root by default') .option('-u, --user <n>', 'username of database / root by default')
.option('-p, --password <n>', 'password of database / empty by default') .option('-p, --password <n>', 'password of database / empty by default')
.option('-d, --database <n>', 'database schema name') .option('-d, --database <n>', 'database schema name')
.option('-r, --ipAddress <n>', 'IP interface of your server / locahost by default')
.option('-n, --portNumber <n>', 'port number for app / 3000 by default') .option('-n, --portNumber <n>', 'port number for app / 3000 by default')
.option('-s, --storageFolder <n>', 'storage folder / current working dir by default / available only with local') .option('-s, --storageFolder <n>', 'storage folder / current working dir by default / available only with local')
.option('-i, --ignoreTables <n>', 'comma separated table names to ignore') .option('-i, --ignoreTables <n>', 'comma separated table names to ignore')
@ -48,6 +49,7 @@ function processInvalidArguments(program) {
exports.handle = program => { exports.handle = program => {
/**************** START : default values ****************/ /**************** START : default values ****************/
program.ipAddress = program.ipAddress || 'localhost';
program.portNumber = program.portNumber || 3000; program.portNumber = program.portNumber || 3000;
program.user = program.user || 'root'; program.user = program.user || 'root';
program.password = program.password || ''; program.password = program.password || '';

Loading…
Cancel
Save