feat: save correct db info
This commit is contained in:
parent
ce893ebc15
commit
c131c3a1fc
|
@ -28,7 +28,15 @@ class configGET extends Route {
|
|||
});
|
||||
}
|
||||
|
||||
await Util.writeConfigToDb(value);
|
||||
await Util.wipeConfigDb();
|
||||
|
||||
const keys = Object.keys(value);
|
||||
for await (const item of keys) {
|
||||
Util.writeConfigToDb({
|
||||
key: item,
|
||||
value: value[item]
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).json({ value });
|
||||
}
|
||||
|
|
|
@ -62,7 +62,15 @@ class Util {
|
|||
};
|
||||
}
|
||||
|
||||
static async writeConfigToDb(config) {
|
||||
static async wipeConfigDb() {
|
||||
try {
|
||||
await db.table('settings').del();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
static async writeConfigToDb(config, wipe = false) {
|
||||
// TODO: Check that the config passes the joi schema validation
|
||||
if (!config || !config.key) return;
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue