From 2023697686dcd585d7958cba6ac35cffc5666b4e Mon Sep 17 00:00:00 2001 From: Carlo Morgenstern Date: Sun, 24 Oct 2021 16:40:47 +0200 Subject: [PATCH] Added optional xivApiKey to CardCreator --- create-card.js | 4 +++- index.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/create-card.js b/create-card.js index 731577a..ede85e0 100644 --- a/create-card.js +++ b/create-card.js @@ -91,8 +91,10 @@ class CardCreator { /** * Creates a new card creator. * @constructor + * @param {string} [xivApiKey] The API key for the XIV API to be used in all requests. */ - constructor() { + constructor(xivApiKey = undefined) { + this.xivApiKey = typeof xivApiKey === 'string' && xivApiKey !== '' ? xivApiKey : undefined; this.isInit = false; } diff --git a/index.js b/index.js index 9261107..99cac18 100644 --- a/index.js +++ b/index.js @@ -11,7 +11,7 @@ const xivApiKey = typeof process.env.XIV_API_KEY === 'string' && process.env.XIV const supportedLanguages = ['en', 'ja', 'de', 'fr']; const app = express(); -const creator = new CardCreator(); +const creator = new CardCreator(xivApiKey); // Initialize caching on disk const diskCache = cacheManager.caching({