diff --git a/README.md b/README.md index c939b7a..b0e3847 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This should display the commands available to you. ### Init -Get an API key. Keys are currently limited due to beta testing. +Get an API key. ``` nodana init @@ -28,15 +28,16 @@ nodana init -y (auto accept Nodana's terms and conditions) ``` -After calling `nodana init`, the CLI will save your API key in a local file. The key will automatically be included in future requests. You can override this by providing the API key manually using the `-k ` option. +After calling `nodana init`, the CLI will save your API key in a local file. The key will automatically be included in future requests. -### During Beta Testing - -During our beta testing period, running `nodana init` will automatically enrol you on the program and you will get your free sats added to your API key automatically. These free sats should give you plenty of time to test out Nodana. +### Create Invoice -### After Beta Testing +Create a Lightning invoice to top up the credit on your API key. -If you have joined after our beta testing period you won't get any sats attached to your API key automatically. You will instead need to run `nodana invoice` to create an invoice, choosing how many sats you would like the invoice to be for. The response will include a url that you can visit to make payment. Don't forget your Lightning wallet. +``` +nodana create invoice + -v (Amount in sats, min: 1k, max: 1m) +``` ### Create Node @@ -44,13 +45,9 @@ Create and start a node. ``` nodana create node - -n - -p - -s -a -w - -x ``` ### Start @@ -85,16 +82,6 @@ Delete a node. nodana delete ``` -### Create Invoice - -Create a Lightning invoice to top up the credit on your API key. - -``` -nodana create invoice - - -v (Amount in sats, min: 1k, max: 1m) -``` - ### Status Check the credit balance for your API key. diff --git a/package.json b/package.json index 6709bcb..8a53751 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nodana/nodana-cli", - "version": "0.3.1", + "version": "0.4.0", "description": "Lightning node infrastructure as a service", "repository": { "type": "git", diff --git a/src/client/index.ts b/src/client/index.ts index a45b23d..1933685 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -26,6 +26,15 @@ export const getAuthHeader = (key: string) => { }; }; +export const cleanOptions = (options: any) => { + const optionsCopy = { ...options }; + + delete optionsCopy.key; + delete optionsCopy.yes; + + return optionsCopy; +}; + export const init = async () => { try { const response = await request._call("/keys", "POST", {}, {}); @@ -41,7 +50,9 @@ export const createNode = async (options: any) => { const key = await getAuthKey(options); try { - return request._call("/containers", "POST", getAuthHeader(key), options); + return request._call("/containers", "POST", getAuthHeader(key), { + config: cleanOptions(options), + }); } catch (e: any) { throw e; } @@ -101,7 +112,12 @@ export const createInvoice = async (options: any) => { const key = await getAuthKey(options); try { - return request._call("/invoices", "POST", getAuthHeader(key), options); + return request._call( + "/invoices", + "POST", + getAuthHeader(key), + cleanOptions(options) + ); } catch (e: any) { throw e; } diff --git a/src/commands/node/create.ts b/src/commands/node/create.ts index 0b7faeb..acad1c5 100644 --- a/src/commands/node/create.ts +++ b/src/commands/node/create.ts @@ -5,8 +5,6 @@ import { error, info, success } from "../../helpers/output"; type Props = { key?: string; - password?: string; - seed?: string; autoLiquidity?: string; webhook?: string; yes?: boolean; diff --git a/src/commands/node/list.ts b/src/commands/node/list.ts index fcd6c8e..10d3ea9 100644 --- a/src/commands/node/list.ts +++ b/src/commands/node/list.ts @@ -28,7 +28,7 @@ const print = (nodes: any) => { console.log(chalk.yellow("ID:"), node.id); node.name && console.log(chalk.yellow("Name:"), node.name); console.log(chalk.yellow("Connection Url:"), node.connectionUrl); - console.log(chalk.yellow("Age"), getDurationString(node.age)); + console.log(chalk.yellow("Age"), node.age); console.log(chalk.yellow("Fee"), `${node.fee.toLocaleString()} sats`); console.log(chalk.yellow("Status"), node.status); console.log(chalk.yellow("Version"), node.version); diff --git a/src/commands/node/stop.ts b/src/commands/node/stop.ts index 159dfc4..d707964 100644 --- a/src/commands/node/stop.ts +++ b/src/commands/node/stop.ts @@ -1,19 +1,19 @@ const chalk = require("chalk"); import * as client from "../../client"; import { error, info } from "../../helpers/output"; -import { sleep } from "../../helpers/date"; +// import { sleep } from "../../helpers/date"; type Options = { key?: string; }; -const DELAY = 5000; +// const DELAY = 5000; export default async (id: string, options: Options) => { try { info(`Stopping. Please wait...`); const response = await client.stopNode(id, options); - await sleep(DELAY); // wait 5 seconds instead of blocking thread on api + // await sleep(DELAY); // wait 5 seconds instead of blocking thread on api print(response); } catch (e: any) { diff --git a/tests/client/index.test.ts b/tests/client/index.test.ts index 80e3760..566dc31 100644 --- a/tests/client/index.test.ts +++ b/tests/client/index.test.ts @@ -76,7 +76,11 @@ describe("client", () => { "/containers", "POST", authHeader, - options + { + config: { + password: "12345", + }, + } ); }); }); @@ -153,7 +157,10 @@ describe("client", () => { "/invoices", "POST", authHeader, - options + { + value: 1000, + memo: "Test memo", + } ); }); });