summaryrefslogtreecommitdiff
path: root/routes/settings.js
blob: 59b9f804ddc90f90f9779c66064e1697f3688b8c (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
"use strict";

const config = require("../server/js/config");

function settings(req, res)
{
	res.render('settings', {showSearchBar: true, config: config.loadedConfig});
};

function save(req, res)
{
	let newConfig = {
		'settings': {
			'nsfw_content': ((req.body.nsfw === "on") ? true : false),
			'port': ((!isNaN(parseInt(req.body.port))) ? parseInt(req.body.port) : 3000),
			'tor': {
				'host': ((req.body.torHost) ? req.body.torHost : undefined),
				'port': ((!isNaN(parseInt(req.body.torPort))) ? parseInt(req.body.torPort) : undefined)
			}
		}
	};

	config.createConfig(newConfig);
	config.loadConfig();

	res.render('settings', {showSearchBar: true, config: config.loadedConfig});
};

module.exports = {settings, save};