Browse Source

refactor : console prints

pull/13/head
oof1lab 7 years ago
parent
commit
d4ac1033e9
  1. 12
      bin/index.js
  2. 13
      index.js
  3. 2
      lib/util/cmd.helper.js
  4. 3
      lib/util/data.helper.js
  5. 18
      lib/xapi.js
  6. 43
      package-lock.json
  7. 11
      package.json

12
bin/index.js

@ -30,9 +30,7 @@ let mysqlPool = mysql.createPool(sqlConfig);
/**************** START : setup Xapi ****************/
console.log('');
console.log('');
console.log(' Generating APIs at speed of your thoughts.. ');
console.log('');
console.log(' REST APIs at the speed of thought.. ');
console.log('');
let t = process.hrtime();
@ -44,10 +42,12 @@ moreApis.init((err, results) => {
var t1 = process.hrtime(t);
var t2 = t1[0]+t1[1]/1000000000
console.log('| |');
console.log("| xmysql took : %d seconds",dataHelp.round(t2,1));
console.log('| |');
console.log(' ');
console.log(" Xmysql took : %d seconds",dataHelp.round(t2,1));
console.log(' ');
console.log(' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ');
})
/**************** END : setup Xapi ****************/

13
index.js

@ -1,4 +1,5 @@
#! /usr/bin/env node
const morgan = require('morgan');
const bodyParser = require('body-parser');
const express = require('express');
@ -30,9 +31,7 @@ let mysqlPool = mysql.createPool(sqlConfig);
/**************** START : setup Xapi ****************/
console.log('');
console.log('');
console.log(' Generating APIs at speed of your thoughts.. ');
console.log('');
console.log(' REST APIs at the speed of thought.. ');
console.log('');
let t = process.hrtime();
@ -44,10 +43,12 @@ moreApis.init((err, results) => {
var t1 = process.hrtime(t);
var t2 = t1[0]+t1[1]/1000000000
console.log('| |');
console.log("| xmysql took : %d seconds",dataHelp.round(t2,1));
console.log('| |');
console.log(' ');
console.log(" Xmysql took : %d seconds",dataHelp.round(t2,1));
console.log(' ');
console.log(' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ');
})
/**************** END : setup Xapi ****************/

2
lib/util/cmd.helper.js

@ -11,7 +11,7 @@ program.on('--help', () => {
})
program
.version('0.1.8')
.version('0.1.9')
.option('-h, --host <n>', 'hostname')
.option('-d, --database <n>', 'database schema name')
.option('-u, --user <n>', 'username of database / root by default')

3
lib/util/data.helper.js

@ -1,5 +1,6 @@
'use strict';
exports.findOrInsertObjectArrayByKey = (obj, key, array) => {
let found = 0;
@ -36,7 +37,7 @@ exports.findObjectInArrayByKey = (key, value, objArray) => {
};
exports.round = function(number, precision) {
exports.round = function (number, precision) {
var factor = Math.pow(10, precision);
var tempNumber = number * factor;
var roundedTempNumber = Math.round(tempNumber);

18
lib/xapi.js

@ -37,9 +37,9 @@ class Xapi {
this.mysql.init((err, results) => {
this.app.use(this.urlMiddleware)
this.setupRoutes()
let stat = this.setupRoutes()
this.app.use(this.errorMiddleware)
cbk(err, results)
cbk(err, stat)
})
@ -210,12 +210,14 @@ class Xapi {
let statStr = ' Generated: ' + stat.apis + ' REST APIs for ' + stat.tables + ' tables '
console.log(' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ');
console.log('| |');
console.log('| |');
console.log('| ' + statStr);
console.log('| |');
console.log('| |');
console.log(' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ');
console.log(' ');
console.log(' Database : %s',this.config.database);
console.log(' Number of resources : %s',stat.tables);
console.log(' ');
console.log(' REST APIs Generated : %s'.green.bold,stat.apis );
console.log(' ');
return stat
}
async create(req, res) {

43
package-lock.json generated

@ -1,6 +1,6 @@
{
"name": "xmysql",
"version": "0.1.0",
"version": "0.1.8",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -40,7 +40,8 @@
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
},
"basic-auth": {
"version": "2.0.0",
@ -76,6 +77,7 @@
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
"integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
"dev": true,
"requires": {
"balanced-match": "1.0.0",
"concat-map": "0.0.1"
@ -84,7 +86,8 @@
"browser-stdout": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz",
"integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8="
"integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=",
"dev": true
},
"busboy": {
"version": "0.2.14",
@ -151,7 +154,8 @@
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"concat-stream": {
"version": "1.6.0",
@ -253,7 +257,8 @@
"diff": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz",
"integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww=="
"integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==",
"dev": true
},
"ee-first": {
"version": "1.1.1",
@ -273,7 +278,8 @@
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true
},
"etag": {
"version": "1.8.1",
@ -367,12 +373,14 @@
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true
},
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"dev": true,
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
@ -385,17 +393,20 @@
"growl": {
"version": "1.10.3",
"resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz",
"integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q=="
"integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==",
"dev": true
},
"has-flag": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE="
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=",
"dev": true
},
"he": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0="
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=",
"dev": true
},
"http-errors": {
"version": "1.6.2",
@ -424,6 +435,7 @@
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true,
"requires": {
"once": "1.4.0",
"wrappy": "1.0.2"
@ -481,6 +493,7 @@
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "1.1.8"
}
@ -502,6 +515,7 @@
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-4.0.1.tgz",
"integrity": "sha512-evDmhkoA+cBNiQQQdSKZa2b9+W2mpLoj50367lhy+Klnx9OV8XlCIhigUnn1gaTFLQCa0kdNhEGDr0hCXOQFDw==",
"dev": true,
"requires": {
"browser-stdout": "1.3.0",
"commander": "2.11.0",
@ -519,6 +533,7 @@
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"dev": true,
"requires": {
"ms": "2.0.0"
}
@ -601,6 +616,7 @@
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
"requires": {
"wrappy": "1.0.2"
}
@ -613,7 +629,8 @@
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
},
"path-to-regexp": {
"version": "0.1.7",
@ -851,6 +868,7 @@
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz",
"integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==",
"dev": true,
"requires": {
"has-flag": "2.0.0"
}
@ -907,7 +925,8 @@
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
},
"xtend": {
"version": "4.0.1",

11
package.json

@ -1,16 +1,17 @@
{
"name": "xmysql",
"version": "0.1.8",
"version": "0.1.9",
"description": "One command to generate REST APIs for any MySql database",
"main": "index.js",
"scripts": {
"test": "./node_modules/.bin/mocha tests/*.js --exit"
},
"keywords": [
"mysql rest api generator",
"mysql rest api json",
"create rest api for sql database",
"node mysql rest api"
"mysql-rest-api-generator",
"node-mysql-rest-api",
"rest",
"restful",
"rest-apis"
],
"engines": {
"node": ">= 7.6.0"

Loading…
Cancel
Save