const express = require("express");
const router = express.Router();
const DeviceLogController = require("../controller/device.log.controller");

router.use(express.urlencoded({ extended: false }));
router.use(express.json());

// Device Log Save route
router.post("/", async (req, res) => {
  try {
    // Token Control Middleware
    const result = await DeviceLogController.logSave(
      req.body.token,
      req.body.device_id,
      req.body.remote_name,
      req.body.remote_type,
      req.body.operating_type,
    );

    return res.status(200).json({
      error: false,
      result
    });
  } catch (error) {
    res.status(400).json({
      error: true,
      result: error.message
    });
  }
});

module.exports = router;
