rsshub
Version:
Make RSS Great Again!
61 lines (59 loc) • 1.95 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import path from "node:path";
//#region lib/routes/hellogithub/report.ts
init_esm_shims();
const types = {
tiobe: "编程语言",
netcraft: "服务器",
"db-engines": "数据库"
};
const route = {
path: "/ranking/:type?",
example: "/hellogithub/ranking",
name: "榜单报告",
maintainers: ["moke8", "nczitzk"],
handler,
description: `| 编程语言 | 服务器 | 数据库 |
| -------- | -------- | ---------- |
| tiobe | netcraft | db-engines |`
};
async function handler(ctx) {
let type = ctx.req.param("type") ?? "tiobe";
type = type === "webserver" ? "netcraft" : type === "db" ? "db-engines" : type;
const rootUrl = "https://hellogithub.com";
const currentUrl = `${rootUrl}/report/${type}`;
const data = (await got_default({
method: "get",
url: `${rootUrl}/_next/data/${(await got_default({
method: "get",
url: rootUrl
})).data.match(/"buildId":"(.*?)",/)[1]}/zh/report/${type}.json`
})).data.pageProps;
const items = [{
guid: `${type}:${data.year}${data.month}`,
title: `${data.year}年${data.month}月${types[type]}排行榜`,
link: currentUrl,
pubDate: parseDate(`${data.year}-${data.month}`, "YYYY-M"),
description: art(path.join(__dirname, "templates/report-4864adbe.art"), {
tiobe_list: type === "tiobe" ? data.list : void 0,
active_list: data.active_list,
all_list: data.all_list,
db_list: type === "db-engines" ? data.list : void 0
})
}];
return {
title: `HelloGitHub - ${types[type]}排行榜`,
link: currentUrl,
item: items
};
}
//#endregion
export { route };