switched to new way :)
This commit is contained in:
parent
b03a2a25f1
commit
f22d182c8f
30 changed files with 0 additions and 0 deletions
38
src-old/config.ts
Normal file
38
src-old/config.ts
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import dotenv from 'dotenv';
|
||||
import type { Config } from './types.js';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
function env(key: string, fallback?: string): string {
|
||||
const val = process.env[key];
|
||||
if (val !== undefined) return val;
|
||||
if (fallback !== undefined) return fallback;
|
||||
throw new Error(`Missing required environment variable: ${key}`);
|
||||
}
|
||||
|
||||
function envInt(key: string, fallback: number): number {
|
||||
const val = process.env[key];
|
||||
return val ? parseInt(val, 10) : fallback;
|
||||
}
|
||||
|
||||
export function loadConfig(cliUrls?: string[]): Config {
|
||||
const envUrls = process.env['TRADE_URLS']
|
||||
? process.env['TRADE_URLS'].split(',').map((u) => u.trim())
|
||||
: [];
|
||||
|
||||
const tradeUrls = cliUrls && cliUrls.length > 0 ? cliUrls : envUrls;
|
||||
|
||||
return {
|
||||
tradeUrls,
|
||||
poe2LogPath: env(
|
||||
'POE2_LOG_PATH',
|
||||
'C:\\Program Files (x86)\\Steam\\steamapps\\common\\Path of Exile 2\\logs\\Client.txt',
|
||||
),
|
||||
poe2WindowTitle: env('POE2_WINDOW_TITLE', 'Path of Exile 2'),
|
||||
browserUserDataDir: env('BROWSER_USER_DATA_DIR', './browser-data'),
|
||||
travelTimeoutMs: envInt('TRAVEL_TIMEOUT_MS', 15000),
|
||||
stashScanTimeoutMs: envInt('STASH_SCAN_TIMEOUT_MS', 10000),
|
||||
waitForMoreItemsMs: envInt('WAIT_FOR_MORE_ITEMS_MS', 20000),
|
||||
betweenTradesDelayMs: envInt('BETWEEN_TRADES_DELAY_MS', 5000),
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue