(ctx)
| 57 | }; |
| 58 | |
| 59 | async function handler(ctx) { |
| 60 | const user = ctx.req.param('user'); |
| 61 | const repo = ctx.req.param('repo'); |
| 62 | const state = ctx.req.param('state') ?? 'open'; |
| 63 | const labels = ctx.req.param('labels'); |
| 64 | |
| 65 | const host = `https://github.com/${user}/${repo}/pulls`; |
| 66 | const url = `https://api.github.com/repos/${user}/${repo}/issues`; // every PR is also an issue |
| 67 | |
| 68 | const headers = { Accept: 'application/vnd.github.v3+json' }; |
| 69 | if (config.github && config.github.access_token) { |
| 70 | headers.Authorization = `token ${config.github.access_token}`; |
| 71 | } |
| 72 | const limit = ctx.req.query('limit'); |
| 73 | const response = await ofetch(url, { |
| 74 | query: { |
| 75 | state, |
| 76 | labels, |
| 77 | sort: 'created', |
| 78 | direction: 'desc', |
| 79 | per_page: limit ? Number.parseInt(limit) : 100, |
| 80 | }, |
| 81 | headers, |
| 82 | }); |
| 83 | const data = response.filter((item) => item.pull_request); |
| 84 | |
| 85 | return { |
| 86 | allowEmpty: true, |
| 87 | title: `${user}/${repo} ${state.replace(/^\S/, (s) => s.toUpperCase())} Pull Requests${labels ? ' - ' + labels : ''}`, |
| 88 | link: host, |
| 89 | item: data.map((item) => ({ |
| 90 | title: item.title, |
| 91 | author: item.user.login, |
| 92 | description: item.body ? md.render(item.body) : 'No description', |
| 93 | pubDate: parseDate(item.created_at), |
| 94 | link: item.html_url, |
| 95 | })), |
| 96 | }; |
| 97 | } |
nothing calls this directly
no test coverage detected