16 lines
484 B
TypeScript
16 lines
484 B
TypeScript
import axios from "axios";
|
|
import { env } from "node:process";
|
|
|
|
const list = axios.get("https://www.peeringdb.com/api/net",{
|
|
headers: {
|
|
"User-Agent": "NET186-AS-SET/1.0.0",
|
|
"Authorization": `Api-Key ${env.PDB_TOKEN}`,
|
|
"Content-Type": "application/json"
|
|
}
|
|
});
|
|
|
|
export const getNetName = async (ASN: number): Promise<string> => {
|
|
const answer = (await list).data;
|
|
return (answer.data.find((k: any) => k.asn === ASN) ?? { name: `AS${ASN}` })
|
|
.name;
|
|
}; |