diff --git a/app/controllers/test.controller.js b/app/controllers/test.controller.js index 74ca5f6..1602320 100644 --- a/app/controllers/test.controller.js +++ b/app/controllers/test.controller.js @@ -12,22 +12,15 @@ exports.APIstatus = async (req, res) => { try { - // var dbConfig = { - // server:process.env.HOST, - // database:process.env.DATABASE, - // user:process.env.USER_NAME, - // password:process.env.PASSWORD, - // port: Number(process.env.PORT) - // }; - // await sql.connect(dbConfig) - // result = await sql.query`select * from applicants where id = 66` - // console.log(result) - - + // call token api token_data = await TestHelper.TokenAPI(); + // store api status only apiArr = [ ]; + // store server status only serverArr = [ ]; + // store database status only dbArr = [ ]; + // store fail status only StatusFailArr = [ ]; ApiData = await JSON.parse(process.env.STATUSARRAY); if (token_data.status == 200) { apiArr.push({ "Api" : "Token API" , "StatusCode" : token_data.status , "Status" : "Up"}); } @@ -40,7 +33,8 @@ exports.APIstatus = async (req, res) => if (object.header == 1 && token_data.status == 200) { request_header = "Bearer"+" "+token_data.data.token; reqObj = {url: URL, method: object.method,json: true,body: request_object,headers : { 'Content-Type' : 'application/json' , 'Authorization' : request_header }} } else { reqObj = {url: URL,method: object.method,json: true,body: request_object} } request(reqObj, async function (error, response, body) { - if (response == undefined) + // because some times some api's could not send respond + if (response == undefined) { if (object.type == "api") { apiArr.push({ "Api" : object.name , "StatusCode" : 502, "Status" : "Down"}); StatusFailArr.push("down") } if (object.type == "server") { serverArr.push({ "Api" : object.name , "StatusCode" : 502 , "Status" : "Down"}); StatusFailArr.push("down") } @@ -87,6 +81,7 @@ exports.SingleApiStatus = async (req, res) => { ApiName = req.body.api; ApiData = JSON.parse(process.env.STATUSARRAY); + // call token api token_data = await TestHelper.TokenAPI(); if (ApiName == "Token API") { diff --git a/app/views/status.ejs b/app/views/status.ejs index 142f1a6..dcbf32c 100644 --- a/app/views/status.ejs +++ b/app/views/status.ejs @@ -361,7 +361,7 @@ var api = $(evt.target).parent().parent("tr").find("td:nth-child(1)").text(); $.ajax({ type: "post", - url: "http://localhost:8888/api/SingleApiStatus", + url: "/api/SingleApiStatus", data: {api : api}, success: function(response) { if (response.success == true)