Add reload settings method, reload settings when DB updated

This commit is contained in:
Alex Holliday committed 2024-09-26 15:45:54 +08:00
1 parent 0832e8438a
commit 97419b436c
2 files changed
+14

No files matched your search

+13
View File
@@ -22,6 +22,19 @@ class SettingsService {
}
}
async reloadSettings() {
try {
this.settings = await AppSettings.findOne();
if (!this.settings) {
throw new Error("Settings not found");
}
} catch (error) {
error.service === undefined ? (error.service = SERVICE_NAME) : null;
error.method === undefined ? (error.method = "reloadSettings") : null;
throw error;
}
}
getSettings() {
if (!this.settings) {
throw new Error("Settings have not been loaded");