Getting Started

Learn how to install, configure, and start using the discloud.app NPM library to manager your Discloud application.

πŸ“¦ Installation

You can install the discloud.app library using your preferred package manager:

npm install discloud.app

πŸ”‘ Obtaining Your API Token

Before using the library, you need to obtain your Discloud API Token.

For detailed instructions on how to get your API token, please visit here.

πŸš€ Basic Setup

Environment Variables Configuration

1

Create a .env file in your project root to store your API token securely:

.env
DISCLOUD_TOKEN=your_api_token_here
2

Install the dotenv package to load environment variables:

npm install dotenv
3

Then use it in your application:

index.js
require("dotenv").config(); // Load environment variables
const { discloud } = require("discloud.app");

async function main() {
  try {
    // Authenticate using environment variable
    await discloud.login(process.env.DISCLOUD_TOKEN);
    console.log("Successfully authenticated with Discloud!");

    // Your application logic here...
  } catch (error) {
    console.error("Authentication failed:", error.message);
  }
}

main();

🎯 Your First API Call

Let's test the connection by fetching information about your applications:

test-connection.js
require("dotenv").config(); // Load environment variables
const { discloud } = require("discloud.app");

async function testConnection() {
  try {
    // Authenticate
    await discloud.login(process.env.DISCLOUD_TOKEN);

    // Fetch all your applications
    const apps = await discloud.apps.fetch("all");

    console.log(`Found ${apps.size} applications:`);
    apps.forEach((app, id) => {
      console.log(`- ${app.name} (ID: ${id})`);
    });
  } catch (error) {
    console.error("Error:", error.message);
  }
}

testConnection();

πŸ“ TypeScript Support

The library includes full TypeScript support with type definitions:


Last updated