Skip to content
Closed
Changes from all commits
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
41 changes: 25 additions & 16 deletions src/lib/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,22 +222,11 @@ async function fetchPinnedRepos(username: string, token?: string): Promise<Pinne
})) ?? [];
}

/**
* Task④: ユーザープロフィール・組織・ピン留めリポジトリを取得
* REST /users/:username + /users/:username/orgs + GraphQL pinnedItems
* @throws {UserNotFoundError} ユーザーが存在しない場合
* @throws {RateLimitError} APIレート制限に達した場合
*/
export async function fetchUserProfile(
username: string,
token?: string
): Promise<UserProfile> {
const [profile, orgs, pinnedRepos] = await Promise.all([
fetchBasicProfile(username, token),
fetchOrganizations(username, token),
fetchPinnedRepos(username, token),
]);

function buildUserProfile(
profile: GitHubUser,
orgs: GitHubOrg[],
pinnedRepos: PinnedRepo[]
): UserProfile {
return {
login: profile.login,
avatar_url: profile.avatar_url,
Expand All @@ -256,6 +245,26 @@ export async function fetchUserProfile(
};
}

/**
* Task④: ユーザープロフィール・組織・ピン留めリポジトリを取得

* REST /users/:username + /users/:username/orgs + GraphQL pinnedItems
* @throws {UserNotFoundError} ユーザーが存在しない場合
* @throws {RateLimitError} APIレート制限に達した場合
*/
export async function fetchUserProfile(
username: string,
token?: string
): Promise<UserProfile> {
const [profile, orgs, pinnedRepos] = await Promise.all([
fetchBasicProfile(username, token),
fetchOrganizations(username, token),
fetchPinnedRepos(username, token),
]);

return buildUserProfile(profile, orgs, pinnedRepos);
}

// ===== 2. fetchRepositories =====

type RepoLanguageNode = {
Expand Down
Loading