SettingHelpers
Overview
This file contains helper functions for managing audio settings in the kweenb
application. It facilitates the retrieval, update, export, and import of settings relevant to audio processing and routing configurations.
The SettingHelpers.ts
module interacts with the Setting
model to perform CRUD operations. This is particularly important for managing audio settings related to both the KweenB application and the bee audio devices it supports.
Functions
getAllSettings
const getAllSettings = async (): Promise<ISettings>
Retrieves all the settings from the database and organizes them into a structured format that includes both beeAudioSettings
and kweenBAudioSettings
. It utilizes inner functions to streamline the search for individual settings.
Return Type: Promise<ISettings>
updateSetting
const updateSetting = async (setting: ISetting)
Updates an existing setting in the database, or creates it if it does not exist. It validates that a key
is provided.
Parameters:
setting
: An object of typeISetting
which contains akey
andvalue
to be updated in the database.
exportSettings
const exportSettings = async (filePath: string)
Exports all settings to a JSON file at the specified path. If no valid path is provided, no action is taken.
Parameters:
filePath
: A string that specifies where the settings JSON file will be exported.
importSettings
const importSettings = async (filePath: string)
Imports settings from a specified JSON file and updates the database accordingly. Validates that the contents of the JSON file conform to the expected structure before proceeding with the import.
Parameters:
filePath
: A string that specifies the path of the JSON file to be imported.