From c72d9b0ed15d2951c6aada4836a462fd2aca96c4 Mon Sep 17 00:00:00 2001 From: wukko Date: Sun, 20 Aug 2023 16:58:04 +0600 Subject: [PATCH] change cookie path capitalization for consistency with other env stuff --- docker-compose.example.yml | 4 +++- src/modules/processing/cookie/manager.js | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 20cf43c6..bd7d9157 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -20,7 +20,9 @@ services: - apiURL=https://co.wuk.sh/ # replace apiName with your instance's distinctive name - apiName=eu-nl - + # if you want to use cookies when fetching data from services, uncomment the next line + #- cookiePath=/cookies.json + # see src/modules/processing/cookie/cookies_example.json for example file. cobalt-web: build: . diff --git a/src/modules/processing/cookie/manager.js b/src/modules/processing/cookie/manager.js index 2e585b12..437100a0 100644 --- a/src/modules/processing/cookie/manager.js +++ b/src/modules/processing/cookie/manager.js @@ -3,16 +3,16 @@ import { readFile, writeFile } from 'fs/promises'; import { parse as parseSetCookie, splitCookiesString } from 'set-cookie-parser'; const WRITE_INTERVAL = 60000, - COOKIE_PATH = process.env.COOKIE_PATH, + cookiePath = process.env.cookiePath, COUNTER = Symbol('counter'); let cookies = {}, dirty = false, intervalId; const setup = async () => { try { - if (!COOKIE_PATH) return; + if (!cookiePath) return; - cookies = await readFile(COOKIE_PATH, 'utf8'); + cookies = await readFile(cookiePath, 'utf8'); cookies = JSON.parse(cookies); intervalId = setInterval(writeChanges, WRITE_INTERVAL) } catch { /* no cookies for you */ } @@ -24,7 +24,7 @@ function writeChanges() { if (!dirty) return; dirty = false; - writeFile(COOKIE_PATH, JSON.stringify(cookies, null, 4)).catch(() => { + writeFile(cookiePath, JSON.stringify(cookies, null, 4)).catch(() => { clearInterval(intervalId) }) }