Add reload settings method, reload settings when DB updated
This commit is contained in:
1 parent
0832e8438a
commit
97419b436c
2 files changed
+14
No files matched your search
@@ -31,6 +31,7 @@ const updateAppSettings = async (req, res, next) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const settings = await req.db.updateAppSettings(req.body);
|
const settings = await req.db.updateAppSettings(req.body);
|
||||||
|
await req.settingsService.reloadSettings();
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.UPDATE_APP_SETTINGS,
|
msg: successMessages.UPDATE_APP_SETTINGS,
|
||||||
|
|||||||
@@ -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() {
|
getSettings() {
|
||||||
if (!this.settings) {
|
if (!this.settings) {
|
||||||
throw new Error("Settings have not been loaded");
|
throw new Error("Settings have not been loaded");
|
||||||
|
|||||||
Reference in new issue
Block a user