mirror of https://github.com/Hypfer/Valetudo.git
30 lines
873 B
JavaScript
30 lines
873 B
JavaScript
const CapabilityRouter = require("./CapabilityRouter");
|
|
|
|
class QuirksCapabilityRouter extends CapabilityRouter {
|
|
initRoutes() {
|
|
this.router.get("/", async (req, res) => {
|
|
try {
|
|
res.json(await this.capability.getQuirks());
|
|
} catch (e) {
|
|
this.sendErrorResponse(req, res, e);
|
|
}
|
|
});
|
|
|
|
this.router.put("/", this.validator, async (req, res) => {
|
|
if (req.body.id && req.body.value) {
|
|
try {
|
|
await this.capability.setQuirkValue(req.body.id, req.body.value);
|
|
|
|
res.sendStatus(200);
|
|
} catch (e) {
|
|
this.sendErrorResponse(req, res, e);
|
|
}
|
|
} else {
|
|
res.sendStatus(400);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = QuirksCapabilityRouter;
|