From 351b7527ed1fdf562340c2565e919b1c1616cfe0 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Mon, 21 Oct 2024 16:14:43 +0800 Subject: [PATCH] Remove redundant check --- Server/service/settingsService.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Server/service/settingsService.js b/Server/service/settingsService.js index 130de2934..9f44f7d07 100644 --- a/Server/service/settingsService.js +++ b/Server/service/settingsService.js @@ -1,4 +1,3 @@ -import AppSettings from "../db/models/AppSettings.js"; const SERVICE_NAME = "SettingsService"; const envConfig = { logLevel: undefined, @@ -30,7 +29,8 @@ class SettingsService { * Constructs a new SettingsService * @constructor * @throws {Error} - */ constructor() { + */ constructor(appSettings) { + this.appSettings = appSettings; 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. */ async loadSettings() { try { - const dbSettings = await AppSettings.findOne(); + const dbSettings = await this.appSettings.findOne(); if (!this.settings) { throw new Error("Settings not found"); } @@ -51,10 +51,6 @@ class SettingsService { this.settings[key] = dbSettings[key]; } } - - if (!this.settings) { - throw new Error("Settings not found"); - } return this.settings; } catch (error) { error.service === undefined ? (error.service = SERVICE_NAME) : null;