Move api client initialization to separate config file
This commit is contained in:
parent
8f07661fb2
commit
ca097159dd
2 changed files with 14 additions and 9 deletions
12
lib/config.js
Normal file
12
lib/config.js
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue