mirror of
https://github.com/denoland/deno.git
synced 2024-11-29 16:30:56 -05:00
22 lines
518 B
TypeScript
22 lines
518 B
TypeScript
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
|
|
|
export interface CratesIoMetadata {
|
|
crate: {
|
|
id: string;
|
|
name: string;
|
|
};
|
|
versions: {
|
|
crate: string;
|
|
num: string;
|
|
}[];
|
|
}
|
|
|
|
export async function getCratesIoMetadata(crateName: string) {
|
|
// rate limit
|
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
|
|
const response = await fetch(`https://crates.io/api/v1/crates/${crateName}`);
|
|
const data = await response.json();
|
|
|
|
return data as CratesIoMetadata;
|
|
}
|