Skip to main content

EcoFlow

EcoFlow is the main entry point class of the application containing various components and runtime modules.

Usage

Example Basic usage:

import EcoFlow from "@ecoflow/ecoflow";

const app = new EcoFlow();
app.start();

Modules

API Reference

EcoFlow

Kind: Exported class

new EcoFlow([args])

Create an instance of the EcoFlow class

Example Basic usage:

import EcoFlow from "@ecoflow/ecoflow";

const app = new EcoFlow();
app.start();

Available arguments :

ParameterType (Default)Description
[args]EcoOptionsAn object containing optional arguments.

Methods

Starting the application

start()Promise<EcoFlow>

Asynchronously starts the application by initializing various components and services.

Logs the start of the application and checks if an app needs to be created.

Initializes database connection, router, modules, flow editor, editor, system routes, passport authentication, and starts the server.

Return: A promise that resolves to the EcoFlow instance.

Static Methods

TameTypeDescription
VersionstringThe version of the package.
processCommandsProcessCommandsAn object with process commands and their corresponding values.

Properties

TameTypeDescription
_typeof lodashA reference to the lodash library. Official documentation can be found here
isAuthbooleanA boolean flag indicating whether the authenticated mode is enabled or not.
serverEcoServerRepresents an instance of an EcoServer.
routerEcoRouterRepresents an instance of the EcoRouter.
containerEcoContainerRepresents an instance of the EcoContainer.
socketServerRepresents a socket server instance. Official documentation can be found here
configConfigRepresents the configuration object.
databaseDatabaseRepresents the Database instance.
ecoModuleEcoModuleRepresents the EcoModule instance.
flowEditorEcoFlowEditorRepresents the EcoFlowEditor instance.
serviceServiceRepresents the Service instance.
logLoggerRepresents the Logger instance used for logging.
VersionstringRepresents the version of the software.

TypeScript Properties

ProcessCommands

interface ProcessCommands {
STOP: string;
RESTART: string;
}

EcoOptions

interface EcoOptions {
/**
* An optional ICommand object that represents a command line interface command.
*/
cli?: ICommand;
/**
* An index signature indicating that an object may have any number of properties
* with string keys and any corresponding values.
*/
[key: string]: any;
}

ICommand

interface ICommand {
/** The host of the server at which the server should run. */
Host?: string;

/** The port of server to run on. */
Port?: number;

/** Enable/Disable authentication mode. */
auth?: boolean;

/** The configuration directory of the application. */
configDir?: string;

/** TThe name of the configuration file. */
configName?: string;

/** The root directory where all configuration will be stored. */
userDir?: string;

/** The logging configuration for the application */
logging?: loggerOptions;

/** Enable/Disable running the application in Development environment. */
dev?: boolean;
}