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
}
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
}
UrloptionalType: string
The URL from which the data is loaded.
Note Either Url or Path must be specified.
PathoptionalType: string
The path to the data in the local file system.
Note Either Url or Path must be specified.
StatusoptionalType: 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".
DataRefreshTimeoptionalType: 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).
ParserConfigObject
An object with parsing configurations for the data source. Has the following structure:
{
"Delimiter": string,
"DecimalSeparator": string,
"DataHasHeader": boolean
}
DelimiteroptionalType: string
The delimiter used in the CSV file: ",", ";", "|", or "\t". If omitted, the delimiter is defined automatically.
DecimalSeparatoroptionalType: string
A character that separates decimal parts of numbers in the data: "." or ",".
Default value: ".".
DataHasHeaderoptionalType: 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>.TypeoptionalType: 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>.CaptionoptionalType: string
The caption of the field in the UI. By default, the field’s caption matches its unique name.
<field_name>.SkipoptionalType: 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
}
EnabledoptionalType: boolean
Indicates whether the WSS protocol is enabled. If set to true, a certificate configuration must be provided.
Default value: false.
PFXCertObject
A certificate in the PFX format. Has the following structure:
{
"Path": string,
"Password": string
}
PasswordoptionalType: 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
}
SecurityConfigObject
An object with data access security configurations. Has the following structure:
{
"Auth": {
"Enabled": boolean
},
"CORS": {
"AllowOrigin": string
}
}
CORS.AllowOriginoptionalType: 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
}
DataRefreshTimeoptionalType: 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).
RetryAttemptsoptionalType: 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
}
}
LogLevel.<category>optionalType: 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
}