Valetudo/backend/lib/webserver/capabilityRouters/MapResetCapabilityRouter.js

21 lines
603 B
JavaScript

const CapabilityRouter = require("./CapabilityRouter");
class MapResetCapabilityRouter extends CapabilityRouter {
initRoutes() {
this.router.put("/", this.validator, async (req, res) => {
if (req.body.action === "reset") {
try {
await this.capability.reset();
res.sendStatus(200);
} catch (e) {
this.sendErrorResponse(req, res, e);
}
} else {
res.sendStatus(400);
}
});
}
}
module.exports = MapResetCapabilityRouter;