const {
  getLatestNews,
  getSliderImages,
  getAllHomeData,
  getAffiliates,
} = require("../utils/getQuery");

const router = require("express").Router();

//Latest News
router.get("/latestNews", async (req, res) => {
  try {
    const latestNews = await getLatestNews();
    res.status(200).json(latestNews);
  } catch (error) {
    res.status(500).json(error);
  }
});

//Slider Image
router.get("/sliderImage", async (req, res) => {
  try {
    const sliderImages = await getSliderImages();
    res.status(200).json(sliderImages);
  } catch (error) {
    res.status(500).json(error);
  }
});

// All Data
router.get("/alldata", async (req, res) => {
  try {
    const AllHomeData = await getAllHomeData();
    res.status(200).json(AllHomeData);
  } catch (error) {
    res.status(500).json(error);
  }
});

// Affiliates
router.get("/affiliates", async (req, res) => {
  try {
    const affiliates = await getAffiliates();
    res.status(200).json(affiliates);
  } catch (error) {
    res.status(500).json(error);
  }
});

module.exports = router;
