on/off add

This commit is contained in:
2024-03-06 01:06:40 +03:00
parent c55b16d259
commit 494675c567
8 changed files with 155 additions and 54 deletions

View File

@@ -9,7 +9,7 @@ router.use(express.json());
router.post("/", async (req, res) => {
try {
// Token Control Middleware
const result = await DeviceLogController.set(
const result = await DeviceLogController.logSave(
req.body.token,
req.body.device_id,
req.body.remote_name,

38
route/device.set.route.js Normal file
View File

@@ -0,0 +1,38 @@
const express = require("express");
const router = express.Router();
const DeviceSetController = require("../controller/device.set.controller");
router.use(express.urlencoded({ extended: false }));
router.use(express.json());
// Device Log Save route
router.get(
"/:operating_type/:token/:device_id/:remote_name/:remote_type",
async (req, res) => {
try {
const { token, device_id, remote_name, remote_type, operating_type } =
req.params;
// Token Control Middleware
const result = await DeviceSetController.set(
token,
device_id,
remote_name,
remote_type,
operating_type
);
return res.status(200).json({
error: false,
result
});
} catch (error) {
res.status(400).json({
error: true,
result: error.message
});
}
}
);
module.exports = router;