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.
35 lines (34 loc) • 1.3 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchEolData = fetchEolData;
const axios_1 = __importDefault(require("axios"));
const cache_1 = require("./cache");
const cache = new cache_1.Cache();
async function fetchEolData(product, refreshCache = false) {
// Check cache first (unless refreshCache is requested)
if (!refreshCache) {
const cached = cache.get(product);
if (cached) {
return cached;
}
}
// Fetch from API
try {
const response = await axios_1.default.get(`https://endoflife.date/api/${product}.json`);
// Save to cache
cache.set(product, response.data);
return response.data;
}
catch (error) {
if (axios_1.default.isAxiosError(error)) {
if (error.response?.status === 404) {
throw new Error(`Product "${product}" not found on endoflife.date (404)`);
}
throw new Error(`Failed to fetch EOL data for ${product}: HTTP ${error.response?.status || 'Error'}`);
}
throw new Error(`Failed to fetch EOL data for ${product}: ${error}`);
}
}