Configure the app index

The index.js file acts as the manifest for your Rocketlane Marketplace app. It defines the metadata, entry points, and integration hooks that power your app inside Rocketlane. The app index defines:

Startup configuration: Details like the platform version or Node.js version used.

App behavior and structure: Locations where widgets appear, configuration inputs, and server-side integrations.

When you run rli init, Rocketlane CLI generates a default index.js file. You’ll need to customize this file to suit your app’s specific needs.

How to Configure

After generating the app files:

  • Navigate to your app’s root directory.
  • Open the index.js file.
  • Edit, add, or remove attributes based on your app requirements.

You can also use the rli build command to compile the app after configuring index.js.

Configuration Structure

Rocketlane expects the index.js file to export a JavaScript object with the following structure:

module.exports = {
  version, 								// Version string of the app
  widgets,                // Array of widget configurations
  serverActions,          // Array of server-side actions
  installationFields,     // Function returning installation configuration fields
  clientEvents,           // Path to client events file
  eventHandlers,          // Object defining event handler functions
  scheduledActions        // Array of scheduled actions
};

Key Attributes

version string Required

Version of the app. Follow semantic versioning, e.g., 1.0.0.

widgets array
Defines UI widgets and where they appear in Rocketlane.

Each widget object includes:

const widgets = [
  {
    location: ["project_tab"],         // Array of locations where widget appears
    name: "Projects Tab Sample",       // Display name
    description: "Description text",   // Brief description
    icon: "widgets/public/icon.svg",   // Path to widget icon
    entrypoint: {                      // Entry point configuration
      html: "dist/index.html",         // Path to HTML file
    },
    identifier: "unique-widget-id",    // Unique identifier
    inputFields: () => { ... }         // Optional function returning configuration fields
  }
]

serverActions array

Server-side logic to power your app's backend features.

installationFields method

const installationFields = () => {
    return [
      {
        name: "apiKeySecure",
        label: "API Key",
        type: "AUTH_API_KEY",
        required: true,
        rerenderAllFields: false,
        hidden: false,
        secure: true,
      },
      {
        name: "Sample text field",
        label: "Sample text field",
        type: "TEXT",
        required: true,
        rerenderAllFields: false,
        defaultValue: "Hello world",
        hidden: false,
        secure: false,
        metaData: {
          textFieldMeta: {
            prefix: "Prefix",
            suffix: "Suffix",
          },
        },
      },
      {
        name: "ss0",
        label: "Sample select field 0",
        type: "SINGLE_SELECT",
        required: true,
        rerenderAllFields: false,
        defaultValue: "option1",
        hidden: false,
        secure: false,
        metaData: {
          options: [
            {
              label: "Option 1",
              value: "option1",
            },
            {
              label: "Option 2",
              value: "option2",
            },
          ],
        },
      },
      {
        name: "ss1",
        label: "Sample select field - 1",
        type: "SINGLE_SELECT",
        required: true,
        rerenderAllFields: false,
        hidden: false,
        secure: false,
        metaData: {
          options: () => {
            return [
              {
                label: "Option 1",
                value: "option1",
              },
              {
                label: "Option 2",
                value: "option2",
              },
            ];
          },
        },
      },
      {
        name: "ss2",
        label: "Sample select field - 2",
        type: "SINGLE_SELECT",
        required: true,
        rerenderAllFields: false,
        hidden: false,
        secure: false,
        metaData: {
          options: async () => {
            const response = await axios.get(
              "https://jsonplaceholder.typicode.com/users"
            );
            return response.data.map((user) => ({
              label: user.name,
              value: user.id,
            }));
          },
        },
      },
      {
        name: "Sample number field",
        label: "Sample number field",
        type: "NUMBER",
        required: true,
        rerenderAllFields: false,
        defaultValue: 10,
        secure: true,
        hidden: false,
        metaData: {
          range: {
            min: 0,
            max: 100,
          },
        },
      },
    ];
  }

clientEvents string

Relative location of the Javascript

const clientEvents = "./client-events.js",

eventHandlers object

const eventHandlers = {
    onAppInstall: {
      run: async (r, args) => {
        const installation = args?.context?.installation;
        const appInstallationWebhook = installation.appInstallationWebhook;
        try {
          await r.scheduler.scheduleAppJobs({
            schedulerName: "sa1",
            scheduledAt: Math.floor(Date.now() / 1000) + 20,
          });
        } catch (e) {
          r.logger.log("Error scheduling app jobs", e);
        }
      },
    },
    onAppUninstall: {
      run: (r, args) => {
        console.log("onAppUninstall", r, args);
      },
    },
    onCustomEvent: {
      run: async (r, args) => {
        console.log("onEvent", r, args);
      }
    }
  }

scheduledActions array

const WEBHOOK_SITE = "dummy_url";
const scheduledActions = [
    {
      name: "sa1",
      run: async (r, args) => {
        console.log("sa1", r, args);
        axios.post(WEBHOOK_SITE, {
          message: "Hello world"
        });
        const installation = args.context.installation;
        const appInstallationWebhook = installation.appInstallationWebhook;
        const webhookUrl = appInstallationWebhook.fullUrl;
      },
      interval: 43200, 
    }
  ]