mirror of https://github.com/Hypfer/Valetudo.git
32 lines
887 B
JavaScript
32 lines
887 B
JavaScript
const CapabilityRouter = require("./CapabilityRouter");
|
|
|
|
class MopDockDryManualTriggerCapabilityRouter extends CapabilityRouter {
|
|
initRoutes() {
|
|
const methodMap = {
|
|
"start": () => {
|
|
return this.capability.startDrying();
|
|
},
|
|
"stop": () => {
|
|
return this.capability.stopDrying();
|
|
},
|
|
};
|
|
|
|
this.router.put("/", this.validator, async (req, res) => {
|
|
const method = methodMap[req.body.action];
|
|
|
|
if (method) {
|
|
try {
|
|
await method();
|
|
res.sendStatus(200);
|
|
} catch (e) {
|
|
this.sendErrorResponse(req, res, e);
|
|
}
|
|
} else {
|
|
res.sendStatus(400);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = MopDockDryManualTriggerCapabilityRouter;
|