Move api client initialization to separate config file

This commit is contained in:
ewin 2025-07-29 19:15:20 -04:00
parent 8f07661fb2
commit ca097159dd
Signed by: erin
SSH key fingerprint: SHA256:swjoHhREbZPbWe+gyJNi24d4NAxJSyUIm3fpZj4z3wc
2 changed files with 14 additions and 9 deletions

12
lib/config.js Normal file
View file

@ -0,0 +1,12 @@
import {MediaWikiClient} from './api/mediawiki.js';
export async function getMediawikiClient () {
if (!process.env.MW_USERNAME || !process.env.MW_PASSWORD) {
throw new Error('Environment variables `MW_USERNAME` and `MW_PASSWORD` are required.');
}
// Log into our wiki client
const mw = new MediaWikiClient('https://ffxiv.consolegameswiki.com/mediawiki');
await mw.login(process.env.MW_USERNAME, process.env.MW_PASSWORD);
return mw;
}