summaryrefslogtreecommitdiff
path: root/server/js/config.js
blob: b1e6836c24eb4dd076a5f20587f62b5acfee784f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"use strict";

// Imports
const fs = require('fs');
const path = require('path');
const { ensureFolder, envPaths } = require('./paths');

// Handling Variables
const configFolder = ensureFolder(path.join(envPaths.CONFIG, 'sneedbay'));
const defaultConfigPath = path.join(configFolder, 'config.json');
var loadedConfig = {};

function createConfig()
{
	const defaultConfig = {
		'settings': {
			'nsfw_content': false
		}
	};

	fs.writeFileSync(configPath, JSON.stringify(defaultConfig), 'utf-8');
}

function loadConfig(configPath)
{
	if (!fs.existsSync(configPath))
	{
		createConfig(configPath, defaultConfig);
	}

	this.loadedConfig = JSON.parse(fs.readFileSync(configPath));
}

module.exports = { loadConfig, defaultConfigPath, loadedConfig };