basic login

This commit is contained in:
Guillermo Bonet 2022-06-20 13:52:00 +02:00
parent 8a9dc64917
commit 2e9b91c2fe
1 changed files with 12 additions and 5 deletions

17
main.js
View File

@ -15,7 +15,6 @@ if (!fs.existsSync(configFile)) {
}
const findAll = `Client`;
const apiKey = `Bearer eyJrIjoickI3WVBab0lscldRdk9JV29YYUFKMEdqUDl6UmsyaHIiLCJuIjoiZ3JhZmFuYS1maW5kIiwiaWQiOjF9`;
const config = require(configFile);
const grafanaUrl = config.grafanaUrl;
@ -32,13 +31,16 @@ let nameVariables = new Array;
const regexRawSQL = new RegExp(findAll, 'i');
const user = `guillermo`;
async function main(){
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});/*
});
const answer = await new Promise(resolve => {
rl.question(colors.yellow('Enter your password: '), resolve);
});
@ -46,17 +48,22 @@ async function main(){
console.error(`You need to put a password`.red);
process.exit(0);
}
const passw = `${answer}`;
const credentials = `Basic ` + Buffer.from(`${user}:${passw}`).toString('base64');
rl.close();
*/
console.clear();
console.log(colors.green.bold(`-------------------- Starting process --------------------`));
let responseAllUID = await fetch(urlDashboards, {
method: "GET",
headers: {
"Authorization": apiKey,
"Authorization": credentials,
"Content-Type" : "application/json"
}
});
let allUID = await responseAllUID.json();
for (let i=0; i < allUID.length; i++) {
@ -65,7 +72,7 @@ async function main(){
let response = await fetch(url, {
method: "GET",
headers: {
"Authorization": apiKey,
"Authorization": credentials,
}
});
let data = await response.json();