feat(route/bjp): Support throttling option. (#16847)

This commit is contained in:
Andvari
2024-09-21 16:04:48 +08:00
committed by GitHub
parent d5f9d45123
commit aea69c83d9
+4 -2
View File
@@ -29,7 +29,7 @@ export const route: Route = {
url: 'bjp.org.cn/APOD/today.shtml',
};
async function handler() {
async function handler(ctx) {
const baseUrl = 'https://www.bjp.org.cn';
const listUrl = `${baseUrl}/APOD/list.shtml`;
@@ -46,7 +46,9 @@ async function handler() {
link: `${baseUrl}${e.find('a').attr('href')}`,
pubDate: timezone(parseDate(e.find('span').text().replace(':', ''), 'YYYY-MM-DD'), 8),
};
});
})
.sort((a, b) => b.pubDate - a.pubDate)
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 10);
const items = await Promise.all(
list.map((e) =>