Remove redundant check
This commit is contained in:
1 parent
8279732e16
commit
351b7527ed
1 file changed
+3
-7
@@ -1,4 +1,3 @@
|
|||||||
import AppSettings from "../db/models/AppSettings.js";
|
|
||||||
const SERVICE_NAME = "SettingsService";
|
const SERVICE_NAME = "SettingsService";
|
||||||
const envConfig = {
|
const envConfig = {
|
||||||
logLevel: undefined,
|
logLevel: undefined,
|
||||||
@@ -30,7 +29,8 @@ class SettingsService {
|
|||||||
* Constructs a new SettingsService
|
* Constructs a new SettingsService
|
||||||
* @constructor
|
* @constructor
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/ constructor() {
|
*/ constructor(appSettings) {
|
||||||
|
this.appSettings = appSettings;
|
||||||
this.settings = { ...envConfig };
|
this.settings = { ...envConfig };
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +40,7 @@ class SettingsService {
|
|||||||
* @throws Will throw an error if settings are not found in the database or if settings have not been loaded.
|
* @throws Will throw an error if settings are not found in the database or if settings have not been loaded.
|
||||||
*/ async loadSettings() {
|
*/ async loadSettings() {
|
||||||
try {
|
try {
|
||||||
const dbSettings = await AppSettings.findOne();
|
const dbSettings = await this.appSettings.findOne();
|
||||||
if (!this.settings) {
|
if (!this.settings) {
|
||||||
throw new Error("Settings not found");
|
throw new Error("Settings not found");
|
||||||
}
|
}
|
||||||
@@ -51,10 +51,6 @@ class SettingsService {
|
|||||||
this.settings[key] = dbSettings[key];
|
this.settings[key] = dbSettings[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.settings) {
|
|
||||||
throw new Error("Settings not found");
|
|
||||||
}
|
|
||||||
return this.settings;
|
return this.settings;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||||
|
|||||||
Reference in new issue
Block a user