Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion routes/repos/[owner]/[repo]/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { GithubRepo } from "~types";

defineRouteMeta({
openAPI: {
description: "Get repository readme file on main branch (not cached).",
description: "Get repository info.",
parameters: [
{
name: "owner",
Expand Down Expand Up @@ -35,6 +35,7 @@ export default eventHandler(async (event) => {
stars: rawRepo.stargazers_count,
watchers: rawRepo.subscribers_count,
forks: rawRepo.forks,
issueAndPullCount: rawRepo.open_issues_count,
defaultBranch: rawRepo.default_branch,
};

Expand Down
31 changes: 31 additions & 0 deletions routes/repos/[owner]/[repo]/issue-count.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
defineRouteMeta({
openAPI: {
description: "Get repository open issues count.",
parameters: [
{
name: "owner",
in: "path",
required: true,
schema: { type: "string", example: "unjs" },
},
{
name: "repo",
in: "path",
required: true,
schema: { type: "string", example: "ofetch" },
},
],
},
});

export default eventHandler(async (event) => {
const res = await ghFetch(
`/search/issues?q=repo:${event.context.params.owner}/${event.context.params.repo}+type:issue+state:open&per_page=1`,
);

const count = res.total_count;

return {
count,
};
});
31 changes: 31 additions & 0 deletions routes/repos/[owner]/[repo]/pull-count.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
defineRouteMeta({
openAPI: {
description: "Get repository open pull requests count.",
parameters: [
{
name: "owner",
in: "path",
required: true,
schema: { type: "string", example: "unjs" },
},
{
name: "repo",
in: "path",
required: true,
schema: { type: "string", example: "ofetch" },
},
],
},
});

export default eventHandler(async (event) => {
const res = await ghFetch(
`/search/issues?q=repo:${event.context.params.owner}/${event.context.params.repo}+type:pr+state:open&per_page=1`,
);

const count = res.total_count;

return {
count,
};
});
1 change: 1 addition & 0 deletions types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface GithubRepo {
stars: number;
watchers: number;
forks: number;
issueAndPullCount: number;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
defaultBranch: string;
}

Expand Down