Skip to content

Commit

Permalink
feat(route/bjp): Support throttling option. (DIYgod#16847)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzx-dzx authored Sep 21, 2024
1 parent d5f9d45 commit aea69c8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/routes/bjp/apod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;

Expand All @@ -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) =>
Expand Down

0 comments on commit aea69c8

Please sign in to comment.