checking node status before interactions

This commit is contained in:
Kumaraguru 2024-10-31 03:12:40 +00:00
parent b2a08f9d37
commit 511a4c6ec2
No known key found for this signature in database
GPG Key ID: 4E4555A84ECD28F7
2 changed files with 25 additions and 3 deletions

View File

@ -232,7 +232,7 @@ async function checkNodeStatus() {
await showNavigationMenu();
}
else{
console.log(chalk.red('\nOops...Codex node is not running. Try again after starting the node in port 8080'));
console.log(chalk.red('\nOops...Codex node is not running. Try again after starting the node'));
await showNavigationMenu();
}
} catch (error) {
@ -247,7 +247,9 @@ async function uploadFile() {
console.log(chalk.yellow('Coming soon for Windows!'));
return;
}
const nodeRunning = await isNodeRunning();
if (nodeRunning) {
console.log(chalk.bgYellow('\n ⚠️ Warning: Codex does not encrypt files. Anything uploaded will be available publicly on testnet. The testnet does not provide any guarentees - please do not use in production ⚠️ \n'));
const { filePath } = await inquirer.prompt([
@ -273,6 +275,11 @@ async function uploadFile() {
await showNavigationMenu();
}
}
else{
console.log(chalk.red('\nOops...Codex node is not running. Try again after starting the node'));
await showNavigationMenu();
}
}
async function downloadFile() {
if (platform === 'win32') {
@ -280,6 +287,9 @@ async function downloadFile() {
return;
}
const nodeRunning = await isNodeRunning();
if (nodeRunning) {
const { cid } = await inquirer.prompt([
{
type: 'input',
@ -301,13 +311,20 @@ async function downloadFile() {
await showNavigationMenu();
}
}
else{
console.log(chalk.red('\nOops...Codex node is not running. Try again after starting the node'));
await showNavigationMenu();
}
}
async function showLocalFiles() {
if (platform === 'win32') {
console.log(chalk.yellow('Coming soon for Windows!'));
return;
}
const nodeRunning = await isNodeRunning();
if (nodeRunning) {
try {
const spinner = createSpinner('Fetching local files...').start();
const filesResponse = await runCommand('curl http://localhost:8080/api/codex/v1/data -w \'\\n\'');
@ -350,6 +367,11 @@ async function showLocalFiles() {
await showNavigationMenu();
}
}
else{
console.log(chalk.red('\nOops...Codex node is not running. Try again after starting the node'));
await showNavigationMenu();
}
}
async function main() {

View File

@ -1,6 +1,6 @@
{
"name": "codexstorage",
"version": "1.0.0",
"version": "1.0.2",
"description": "",
"type": "module",
"main": "index.js",