Took 14 minutes
This commit is contained in:
Tobias Hopp 2023-02-03 11:02:04 +01:00
parent 937f825e82
commit 119cf57850
2 changed files with 18 additions and 1 deletions

View File

@ -10,4 +10,5 @@ export enum RequestType {
CHECK = "CHECK", CHECK = "CHECK",
UPDATE = "UPDATE", UPDATE = "UPDATE",
INFO = "INFO", INFO = "INFO",
CLEAR_DB = "CLEAR_DB"
} }

View File

@ -17,6 +17,8 @@ import {ArduinoProxy} from "../../ArduinoProxy";
import {ContainerHelper} from "../../ContainerHelper"; import {ContainerHelper} from "../../ContainerHelper";
import * as os from "os"; import * as os from "os";
import {promisify} from "util"; import {promisify} from "util";
import Drink from "../../database/Drink";
const exec = promisify(require('child_process').exec) const exec = promisify(require('child_process').exec)
const express = require('express'); const express = require('express');
@ -344,7 +346,21 @@ router.ws('/', async (ws, req, next) => {
"contact": "tobi@gaminggeneration.de" "contact": "tobi@gaminggeneration.de"
} }
return WebSocketHandler.answerRequest(msg.data["type"] as RequestType, data); WebSocketHandler.answerRequest(msg.data["type"] as RequestType, data);
break;
}
case RequestType.CLEAR_DB: {
await Drink.deleteMany({});
await Ingredient.deleteMany({});
for( let c of (await Container.find()) )
{
c.content = undefined;
c.save();
}
await iTender.refreshDrinks();
WebSocketHandler.answerRequest(msg.data["type"] as RequestType, true);
break; break;
} }