Configuring the server through the file

All Flexmonster server settings are stored in the flexmonster-config.json file. This file can be used as an alternative to the Admin Panel.

In this guide, you will learn where to find the file and which settings can be configured through it.

Location of the configuration file

See where to find the configuration file on your operating system:

Available configurations

The configuration file uses the JSON format and has the following structure:

{
  "DataSources": DataSourceConfigObject[],
  "WSS": WSSConfigObject,
  "Security": SecurityConfigObject,
  "DataStorage": DataStorageConfigObject,
  "Logging": LoggingConfigObject,
  "Port": string
}
DataSourcesoptional

Type: DataSourceConfigObject[]

Data sources that are available on the server.

WSSoptional

Type: WSSConfigObject

Configurations for the WSS protocol.

Securityoptional

Type: SecurityConfigObject

Configurations for the data access security.

DataStorageoptional

Type: DataStorageConfigObject

Configurations for all data sources.

Loggingoptional

Type: LoggingConfigObject

Logging configurations of the server.

Port

Type: string

The Flexmonster server’s port.

Default value: "9500".

DataSourceConfigObject

An object with the data source configuration. Has the following structure:

{
  "Parser": ParserConfigObject,
  "Schema": SchemaConfigObject,
  "Url": string,
  "Path": string,
  "Id": string,
  "Status": string,
  "DataRefreshTime": integer,
  "Type": string
}
Parseroptional

Type: ParserConfigObject

Parsing rules for the data.

Schemaoptional

Type: SchemaConfigObject

The schema of the data source.

Urloptional

Type: string

The URL from which the data is loaded.

Note Either Url or Path must be specified.

Pathoptional

Type: string

The path to the data in the local file system.

Note Either Url or Path must be specified.

Id

Type: string

An identifier of the data source.

Statusoptional

Type: string

The status of the data source: "enabled" or "disabled". Disabled data sources are not loaded or stored in the server’s internal storage; they are also not available from the client side.

Default value: "enabled".

DataRefreshTimeoptional

Type: integer

Data refresh interval for the data source in minutes measured from the moment the server starts up.

If the DataRefreshTime is specified, it overrides the DataStorage.DataRefreshTime property.

Default value: 0 (automatic refreshing is disabled).

Type

Type: string

The type of the data source: "json" or "csv".

ParserConfigObject

An object with parsing configurations for the data source. Has the following structure:

{
  "Delimiter": string,
  "DecimalSeparator": string,
  "DataHasHeader": boolean
}
Delimiteroptional

Type: string

The delimiter used in the CSV file: ",", ";", "|", or "\t". If omitted, the delimiter is defined automatically.

DecimalSeparatoroptional

Type: string

A character that separates decimal parts of numbers in the data: "." or ",".

Default value: ".".

DataHasHeaderoptional

Type: boolean

Specifies whether the data contains field names (true) or not (false). When set to false, the first data record will be treated as a record with values, and field names in the component will be autogenerated. Learn more about configuring this property for JSON and CSV.

Default value: true.

SchemaConfigObject

An object that defines the data source schema. Each key in the object represents a field's unique name in the data source, and the value defines the field’s configuration. Has the following structure:

{
  "<field_name>": {
    "Type": string,
    "Caption": string,
    "Skip": boolean
  }
}
<field_name>

Type: object

A schema definition for a field.

<field_name>.Typeoptional

Type: string

Data type of the field:

  • "string"—the field stores string data.
  • "integer"—the field stores integral numbers.
  • "double"—the field stores floating-point numbers.
  • "boolean"—the field stores boolean data.
  • "date"—the field stores a date.
  • "datetime"—the field stores a date with a time part.
  • "time"—the field stores time.

If omitted, the data type is defined automatically.

<field_name>.Captionoptional

Type: string

The caption of the field in the UI. By default, the field’s caption matches its unique name.

<field_name>.Skipoptional

Type: boolean

Specifies if the field should be skipped and not loaded from the data source.

Default value: false.

WSSConfigObject

An object with configurations for secure WebSocket (WSS) communication. Has the following structure:

{
  "Enabled": boolean,
  "Certificate": PFXCertObject | PEMCertObject
}
Enabledoptional

Type: boolean

Indicates whether the WSS protocol is enabled. If set to true, a certificate configuration must be provided.

Default value: false.

Certificateoptional

Type: PFXCertObject | PEMCertObject

The SSL certificate for WSS communication.

PFXCertObject

A certificate in the PFX format. Has the following structure:

{
  "Path": string,
  "Password": string
}
Path

Type: string

The path to the .pfx certificate.

Passwordoptional

Type: string

The password to access the certificate. If the certificate does not require a password, skip this property.

PEMCertObject

A certificate in the PEM format. Has the following structure:

{
  "Path": string,
  "KeyPath": string
}
Path

Type: string

The path to the .pem certificate.

KeyPathoptional

Type: string

The URL to a .pem file with the certificate's private key.

SecurityConfigObject

An object with data access security configurations. Has the following structure:

{
  "Auth": {
    "Enabled": boolean
  },
  "CORS": {
    "AllowOrigin": string
  }
}
Authoptional

Type: object

Configures Basic authentication.

Auth.Enabled

Type: boolean

Indicates whether Basic authentication is enabled.

Default value: false.

CORSoptional

Type: object

Configures the cross-origin resource sharing for the server.

CORS.AllowOriginoptional

Type: string

Origins from which the server accepts the requests. Example of several defined origins:

"AllowOrigin": "http://localhost,https://example.com"

Note that if Basic authentication is enabled, specific origins must be provided.

Default value: "*" (requests from all origins are accepted).

DataStorageConfigObject

An object with data storage settings that apply to all data sources. Has the following structure:

{
  "DataRefreshTime": integer,
  "RetryAttempts": integer
}
DataRefreshTimeoptional

Type: integer

The interval in minutes for automatic data refreshing. Is measured from the moment the server starts up. The DataStorage.DataRefreshTime property will be overridden if the DataRefreshTime is configured for a specific data source.

Default value: 0 (automatic refreshing is disabled).

RetryAttemptsoptional

Type: integer

The number of attempts to reconnect to the data source if the initial request fails.

Default value: 3.

LoggingConfigObject

An object that configures the verbosity and scope of the server’s messages for monitoring and troubleshooting. Has the following structure:

{
  "LogLevel": {
    "<category>": string
  }
}
LogLeveloptional

Type: object

Contains log configurations for different categories.

LogLevel.<category>optional

Type: string

The minimum log level applied to the category. Available values: "Info", "Warn", "Error", or "Fatal".

If you use the wildcard (*) for the category, the level is applied to all internal components and libraries.

For more details about logging, see Microsoft documentation.

Default value: "Info".

Example of the configuration file

{
  "DataSources": [
    {
      "Parser": {
        "Delimiter": ",",
        "DecimalSeparator": ".",
        "DataHasHeader": true
      },
      "Url": "https://cdn.flexmonster.com/data/data.csv",
      "Id": "SampleData",
      "Status": "enabled",
      "DataRefreshTime": 10,
      "Type": "csv"
    },
    {
      "Schema": {
        "Count": {
          "Caption": "Name Occurrences"
        },
        "State": {
          "Caption": "US State"
        },
        "Year": {
          "Type": "string",
          "Skip": true
        }
      },
      "Url": "https://cdn.flexmonster.com/data/StateNames.csv",
      "Id": "StateNames",
      "Status": "enabled",
      "Type": "csv"
    }
  ],
  "Security": {
    "Auth": {
      "Enabled": true
    },
    "CORS": {
      "AllowOrigin": "https://example.com"
    }
  },
  "DataStorage": {
    "DataRefreshTime": 0,
    "RetryAttempts": 3
  },
  "Logging": {
    "LogLevel": {
      "*": "Information"
    }
  },
  "Port": 9501
}

See also