change cookie path capitalization for consistency with other env stuff

This commit is contained in:
wukko 2023-08-20 16:58:04 +06:00
parent fd0357e52d
commit c72d9b0ed1
2 changed files with 7 additions and 5 deletions

View file

@ -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: .

View file

@ -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)
})
}