|
|
|
@ -98,9 +98,10 @@ class Xapi {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setupRoutes() { |
|
|
|
|
let stat = {}; |
|
|
|
|
stat.tables = 0; |
|
|
|
|
stat.apis = 0; |
|
|
|
|
let stat = {} |
|
|
|
|
stat.tables = 0 |
|
|
|
|
stat.apis = 0 |
|
|
|
|
stat.routines = 0 |
|
|
|
|
|
|
|
|
|
// console.log('this.config while setting up routes', this.config);
|
|
|
|
|
|
|
|
|
@ -349,9 +350,9 @@ class Xapi {
|
|
|
|
|
this.app.get('/_proc', this.asyncMiddleware(this.proc.bind(this))) |
|
|
|
|
stat.apis += 1 |
|
|
|
|
const procResources = this.mysql.getProcList(true, this.config.apiPrefix) |
|
|
|
|
for (let resource in procResources) { |
|
|
|
|
this.app.post('/_proc/' + procResources[resource], this.asyncMiddleware(this.callProc.bind(this))) |
|
|
|
|
} |
|
|
|
|
this.app.post('/_proc/:proc', this.asyncMiddleware(this.callProc.bind(this))) |
|
|
|
|
stat.routines += procResources.length |
|
|
|
|
stat.apis += procResources.length |
|
|
|
|
/**************** END : call stored procedures ****************/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -361,6 +362,7 @@ class Xapi {
|
|
|
|
|
console.log(' '); |
|
|
|
|
console.log(' Database : %s', this.config.database); |
|
|
|
|
console.log(' Number of Tables : %s', stat.tables); |
|
|
|
|
console.log(' Number of Routines : %s', stat.routines); |
|
|
|
|
console.log(' '); |
|
|
|
|
console.log(' REST APIs Generated : %s'.green.bold, stat.apis); |
|
|
|
|
console.log(' '); |
|
|
|
@ -494,8 +496,8 @@ class Xapi {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async callProc(req, res) { |
|
|
|
|
let query = 'CALL showPeople(??)' |
|
|
|
|
let params = [] |
|
|
|
|
let query = 'CALL ??(?)' |
|
|
|
|
let params = [req.params.proc, Object.values(req.body)] |
|
|
|
|
let results = await this.mysql.exec(query, params) |
|
|
|
|
res.status(200).json(results) |
|
|
|
|
} |
|
|
|
|