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

21 lines
601 B
JavaScript

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