Made the numbers of the config clean

This commit is contained in:
Mathias Wagner
2022-06-12 18:14:36 +02:00
parent 731fcc16ae
commit 2f30d39e72
2 changed files with 7 additions and 4 deletions

View File

@@ -2,10 +2,10 @@ const db = require('../index').database;
const configDefaults = {
"setupDone": "true",
"ping": 25,
"download": 100,
"upload": 50,
"timeLevel": 3,
"ping": "25",
"download": "100",
"upload": "50",
"timeLevel": "3",
"serverId": "none",
"password": "none"
}

View File

@@ -26,6 +26,9 @@ app.patch("/:key", async (req, res) => {
if ((req.params.key === "ping" || req.params.key === "download" || req.params.key === "upload" || req.params.key === "timeLevel") && isNaN(req.body.value))
return res.status(400).json({message: "You need to provide a number in order to change this"});
if (req.params.key === "ping")
req.body.value = req.body.value.split(".")[0];
if (req.params.key === "password" && req.body.value !== "none") req.body.value = await require('bcrypt').hash(req.body.value, 10);
if (!config.update(req.params.key, req.body.value)) return res.status(404).json({message: "The provided key does not exist"});