2022-05-29 09:11:46 +02:00
|
|
|
import path from 'path';
|
|
|
|
|
import fs from 'fs';
|
|
|
|
|
|
2022-08-22 09:50:54 +02:00
|
|
|
export function getConfig(name: string, props: any = undefined) {
|
2022-05-29 09:11:46 +02:00
|
|
|
// Check if the config file exists
|
|
|
|
|
const configPath = path.join(process.cwd(), 'data/configs', `${name}.json`);
|
|
|
|
|
if (!fs.existsSync(configPath)) {
|
|
|
|
|
return {
|
|
|
|
|
props: {
|
|
|
|
|
configName: name,
|
|
|
|
|
config: {
|
|
|
|
|
name: name.toString(),
|
|
|
|
|
services: [],
|
|
|
|
|
settings: {
|
|
|
|
|
searchUrl: 'https://www.google.com/search?q=',
|
|
|
|
|
},
|
2022-07-22 17:18:33 +02:00
|
|
|
modules: {
|
|
|
|
|
'Search Bar': {
|
|
|
|
|
enabled: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-05-29 09:11:46 +02:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const config = fs.readFileSync(configPath, 'utf8');
|
|
|
|
|
// Print loaded config
|
|
|
|
|
return {
|
|
|
|
|
props: {
|
|
|
|
|
configName: name,
|
|
|
|
|
config: JSON.parse(config),
|
2022-08-22 09:50:54 +02:00
|
|
|
...props,
|
2022-05-29 09:11:46 +02:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|