const express = require("express");
const router = express.Router();
const DeviceGetController = require("../controller/device.get.controller");

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

// Device Log Save route
router.get("/:token/:device_id?", async (req, res) => {
  try {
    const { token, device_id } = req.params;

    // Token Control Middleware
    const result = await DeviceGetController.get(token, device_id);

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

module.exports = router;
