Browse Source

refactor: don't require Spotify to be used

Kristian Vos 1 year ago
parent
commit
4625764571
2 changed files with 6 additions and 0 deletions
  1. 1 0
      backend/config/template.json
  2. 5 0
      backend/logic/spotify.js

+ 1 - 0
backend/config/template.json

@@ -33,6 +33,7 @@
 			]
 		},
 		"spotify": {
+			"enabled": false,
 			"clientId": "",
 			"clientSecret": "",
 			"rateLimit": 500,

+ 5 - 0
backend/logic/spotify.js

@@ -88,6 +88,11 @@ class _SpotifyModule extends CoreClass {
 		});
 
 		return new Promise((resolve, reject) => {
+			if (!config.has("apis.spotify") || !config.get("apis.spotify.enabled")) {
+				reject(new Error("Spotify is not enabled."));
+				return;
+			}
+
 			this.rateLimiter = new RateLimitter(config.get("apis.spotify.rateLimit"));
 			this.requestTimeout = config.get("apis.spotify.requestTimeout");