1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-19 11:39:36 +02:00

Server: Reimplemented config system

This commit is contained in:
Paweł Malak 2021-10-21 17:14:25 +02:00
parent 85ee5da025
commit b7de1e3d27
6 changed files with 107 additions and 114 deletions

18
utils/loadConfig.js Normal file
View file

@ -0,0 +1,18 @@
const { readFile } = require('fs/promises');
const checkFileExists = require('../utils/checkFileExists');
const initConfig = require('../utils/init/initConfig');
const loadConfig = async () => {
const configExists = await checkFileExists('data/config.json');
if (!configExists) {
await initConfig();
}
const config = await readFile('data/config.json', 'utf-8');
const parsedConfig = JSON.parse(config);
return parsedConfig;
};
module.exports = loadConfig;