2022-07-12 11:42:38 +01:00
|
|
|
import fs from 'fs';
|
|
|
|
|
|
|
|
export interface ConfigFile {
|
|
|
|
shopName: string;
|
|
|
|
shopNickname: string;
|
2022-07-13 18:09:13 +01:00
|
|
|
regionName: string;
|
|
|
|
serverIp?: string;
|
2022-07-12 11:42:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export class Config {
|
|
|
|
private static cfg: ConfigFile;
|
|
|
|
|
|
|
|
static load() {
|
|
|
|
console.log('Loading config file...');
|
|
|
|
let cfg = fs.readFileSync('./config.json', 'utf-8');
|
|
|
|
let json = JSON.parse(cfg);
|
|
|
|
this.cfg = json as ConfigFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
static getConfig(): ConfigFile {
|
2022-07-13 18:09:13 +01:00
|
|
|
if (!this.cfg)
|
|
|
|
this.load();
|
|
|
|
|
2022-07-12 11:42:38 +01:00
|
|
|
return this.cfg;
|
|
|
|
}
|
|
|
|
}
|