Skip to content

Commit

Permalink
feat(release): add assets info (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW authored Aug 29, 2024
1 parent 5923f1b commit ed96291
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
11 changes: 11 additions & 0 deletions routes/repos/[owner]/[repo]/releases/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ export default eventHandler(async (event) => {
publishedAt: i.published_at,
markdown: i.body,
html: "",
assets:
"assets" in i
? i.assets.map((a) => ({
contentType: a.content_type,
size: a.size,
createdAt: a.created_at,
updatedAt: a.updated_at,
downloadCount: a.download_count,
downloadUrl: a.browser_download_url,
}))
: [],
},
);

Expand Down
11 changes: 11 additions & 0 deletions routes/repos/[owner]/[repo]/releases/latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ export default eventHandler(async (event) => {
publishedAt: i.published_at,
markdown: i.body,
html: await ghMarkdown(i.body, repo, "release-" + i.tag),
assets:
"assets" in i
? i.assets.map((a) => ({
contentType: a.content_type,
size: a.size,
createdAt: a.created_at,
updatedAt: a.updated_at,
downloadCount: a.download_count,
downloadUrl: a.browser_download_url,
}))
: [],
};

return {
Expand Down
10 changes: 10 additions & 0 deletions types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export interface GithubFile {
size: number;
}

export interface GithubReleaseAsset {
contentType: string;
size: number;
createdAt: string;
updatedAt: string;
downloadCount: number;
downloadUrl: string;
}

export interface GithubRelease {
id: number;
tag: string;
Expand All @@ -50,6 +59,7 @@ export interface GithubRelease {
publishedAt: string;
markdown: string;
html: string;
assets: GithubReleaseAsset[];
}

export interface GithubFileData {
Expand Down

0 comments on commit ed96291

Please sign in to comment.