-
Notifications
You must be signed in to change notification settings - Fork 7
/
neu.js
36 lines (32 loc) · 900 Bytes
/
neu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const cname = require("./utils").cname;
const MAP = {
success: "S",
syncing: "Y",
unknown: "U",
fail: "F",
failed: "F",
}
module.exports = async function (siteUrl) {
const name_func = await cname();
const site = await (await fetch(siteUrl)).json();
const repo = await (await fetch("http://mirror.neu.edu.cn/assets/js/repertories.json")).json();
const mirrors = await Promise.all(repo.map(async (item) => {
if (item.title == "")
return null;
let status = "U";
if (item.id.startsWith("mirror")) {
stat = await (await fetch(`http://mirror.neu.edu.cn/assets/js/repertories/${item.id}.json`)).json();
status = (MAP[stat.status] ?? "U") + stat.timestamp.toString();
}
return {
cname: name_func(item.title),
url: item.address,
status,
}
}).filter((e) => e !== null));
return {
site,
info: [],
mirrors,
}
};