Files
auh/src/lib/npm_registry.ts
Indrajith K L 0e561a3fc8 Initial Commit
* Implements Select package.json and parse dependencies
* Implements Bun API to handle package Analysis
* Implements NPM Registry API handlers
* Analyze the cross dependencies between packages
* Implements loading NodeJS versions with search (inclusing LTS)
* Error handling
* Implements Report option to get higher infor about the dependencies
* Implements Upgrade command builder
2026-04-14 22:27:06 +05:30

31 lines
1.1 KiB
TypeScript

const API_BASE_URL = "https://registry.npmjs.org/";
export async function getPackageDetails(packageName: string) {
const packageUrl = `${API_BASE_URL}${packageName}`;
return fetch(packageUrl)
.then(res => {
if (res.status === 404) {
return {
name: packageName,
error: "not-found",
isPrivatePackage: true,
message: "Package not found in npm registry - may be a private package"
};
}
if (!res.ok) {
return {
name: packageName,
error: "fetch-error",
message: `Failed to fetch package (Status: ${res.status})`
};
}
return res.json();
}).catch(error => {
console.error(`Error fetching package ${packageName}:`, error);
return {
name: packageName,
error: "network-error",
message: error.message || "Network error while fetching package"
};
});
}