eol-check
Version:
CLI tool to check End-of-Life (EOL) status of Node.js, package managers, operating systems, dependencies, and databases. Supports HTML reports and GitHub Actions.
32 lines (31 loc) • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchEolData = void 0;
const cache_1 = require("./cache");
const BASE_URL = 'https://endoflife.date/api';
const cache = new cache_1.Cache();
const fetchEolData = async (product, forceRefresh = false) => {
// Check cache first (unless force refresh is requested)
if (!forceRefresh) {
const cached = cache.get(product);
if (cached) {
return cached;
}
}
// Fetch from API
try {
const response = await fetch(`${BASE_URL}/${product}.json`);
if (!response.ok) {
throw new Error(`Failed to fetch EOL data for ${product}: ${response.statusText}`);
}
const data = (await response.json());
// Save to cache
cache.set(product, data);
return data;
}
catch (error) {
console.error(`Error fetching EOL data for ${product}:`, error);
return [];
}
};
exports.fetchEolData = fetchEolData;