status ejs : suseendhiran
This commit is contained in:
parent
6e90549883
commit
c6344d53fa
@ -12,22 +12,15 @@ exports.APIstatus = async (req, res) =>
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// var dbConfig = {
|
// call token api
|
||||||
// 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)
|
|
||||||
|
|
||||||
|
|
||||||
token_data = await TestHelper.TokenAPI();
|
token_data = await TestHelper.TokenAPI();
|
||||||
|
// store api status only
|
||||||
apiArr = [ ];
|
apiArr = [ ];
|
||||||
|
// store server status only
|
||||||
serverArr = [ ];
|
serverArr = [ ];
|
||||||
|
// store database status only
|
||||||
dbArr = [ ];
|
dbArr = [ ];
|
||||||
|
// store fail status only
|
||||||
StatusFailArr = [ ];
|
StatusFailArr = [ ];
|
||||||
ApiData = await JSON.parse(process.env.STATUSARRAY);
|
ApiData = await JSON.parse(process.env.STATUSARRAY);
|
||||||
if (token_data.status == 200) { apiArr.push({ "Api" : "Token API" , "StatusCode" : token_data.status , "Status" : "Up"}); }
|
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 }} }
|
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} }
|
else { reqObj = {url: URL,method: object.method,json: true,body: request_object} }
|
||||||
request(reqObj, async function (error, response, body) {
|
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 == "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") }
|
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;
|
ApiName = req.body.api;
|
||||||
ApiData = JSON.parse(process.env.STATUSARRAY);
|
ApiData = JSON.parse(process.env.STATUSARRAY);
|
||||||
|
// call token api
|
||||||
token_data = await TestHelper.TokenAPI();
|
token_data = await TestHelper.TokenAPI();
|
||||||
if (ApiName == "Token API")
|
if (ApiName == "Token API")
|
||||||
{
|
{
|
||||||
|
|||||||
@ -361,7 +361,7 @@
|
|||||||
var api = $(evt.target).parent().parent("tr").find("td:nth-child(1)").text();
|
var api = $(evt.target).parent().parent("tr").find("td:nth-child(1)").text();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "post",
|
type: "post",
|
||||||
url: "http://localhost:8888/api/SingleApiStatus",
|
url: "/api/SingleApiStatus",
|
||||||
data: {api : api},
|
data: {api : api},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if (response.success == true)
|
if (response.success == true)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user