File size: 726 Bytes
5769f09
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import extractTopTen from "../extractors/topten.extractor.js";
import { getCachedData, setCachedData } from "../helper/cache.helper.js";

export const getTopTen = async (req,res) => {
  // const cacheKey = "topTen";
  try {
    // const cachedResponse = await getCachedData(cacheKey);
    // if (cachedResponse && Object.keys(cachedResponse).length > 0) {
    //   return cachedResponse;
    // }
    const topTen = await extractTopTen();
    // await setCachedData(cacheKey, topTen).catch((err) => {
    //   console.error("Failed to set cache:", err);
    // });
    return topTen;
  } catch (e) {
    console.error(e);
    return c
      .status(500)
      .json({ success: false, error: "Internal Server Error" });
  }
};