/
Settings

Settings

The Settings module makes project settings configured in content available in the project context.

Separating the settings (especially environment-specific settings) out into a content item aids in creating more maintainable code and makes migrations easier.

Dependencies

The Settings module is dependent on the following modules:

The Settings Schema

The Settings schema is a global content schema with one field, “settings”, a JSON field that will accept any valid JSON.

Settings Retrieval

The Settings module will look for content created using the Settings Schema in the current project.

If no such items are found, empty settings content will be created so that module initialization can continue. The settings template endpoint can be used as a starting point to updating the settings content with the expected settings for each module.

If more than one such item is found, the first one found will be used, and a warning will be logged indicating that there are more than one settings content items, and detailing which one is being used to populate the settings.

Settings Access

Once retrieved, the settings will be available under the property “settings” on the project context:

Here is an example of accessing the settings in a function node:

const project = flow.get("project"); const { settings } = project; if (settings.debug) { ... }

This example assumes a reference to the project context has been set in the flow context (See Getting the Project Context).

Methods

refresh

This method retrieves the settings content again and updates the settings in the project context.

Parameters: None

Returns: A promise that resolves when the settings have been refreshed in the project context.

update

This method allows updates to the settings content from code.

Parameters:

  • setting (string): The property on the settings object to update.

  • updatedData (any): The new value for the specified setting.

Returns: A promise that resolves when the setting has been updated and the settings in the project context have been refreshed.

Settings Content Updates

Updating the settings content directly will result in an automatic refresh of the settings in the project context.

This happens via the post data hooks feature of Orbita schemas, through a handler registered with the Data Hooks module.

Settings Template

The Settings module establishes an endpoint that can be used to retrieve an example settings JSON object based on the installed modules:

/oeapi/[Hyphenated Project Name]/settings/template

Related content

Best Practice to Store Configuration 
Best Practice to Store Configuration 
More like this
Content Sync
Content Sync
More like this
Flow Manager
Flow Manager
More like this
How do I use the global variable or global function?
How do I use the global variable or global function?
More like this
Project Context
Project Context
More like this
How to export and import Experience Designer flows using APIs?
How to export and import Experience Designer flows using APIs?
More like this