( configurationUpdates: PartialConfiguration, )
| 124 | } |
| 125 | |
| 126 | export async function patchConfiguration( |
| 127 | configurationUpdates: PartialConfiguration, |
| 128 | ): Promise<boolean> { |
| 129 | try { |
| 130 | const currentConfiguration = structuredClone(configuration); |
| 131 | mergeConfigurations(currentConfiguration, configurationUpdates); |
| 132 | |
| 133 | await db |
| 134 | .collection("configuration") |
| 135 | .updateOne({}, { $set: currentConfiguration }, { upsert: true }); |
| 136 | |
| 137 | await getLiveConfiguration(); |
| 138 | } catch (error) { |
| 139 | const errorMessage = getErrorMessage(error) ?? "Unknown error"; |
| 140 | void addLog( |
| 141 | "patch_configuration_failure", |
| 142 | `Could not patch configuration: ${errorMessage}`, |
| 143 | ); |
| 144 | |
| 145 | return false; |
| 146 | } |
| 147 | |
| 148 | return true; |
| 149 | } |
| 150 | |
| 151 | export async function updateFromConfigurationFile(): Promise<void> { |
| 152 | if (existsSync(SERVER_CONFIG_FILE_PATH)) { |
no test coverage detected