Skip to content

Commit 76d8e90

Browse files
refactor: add data model & return types
1 parent 5e21e4f commit 76d8e90

File tree

4 files changed

+116
-5
lines changed

4 files changed

+116
-5
lines changed
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { User } from "./user";
2+
3+
export class Repo {
4+
id: number;
5+
node_id: string;
6+
name: string;
7+
full_name: string;
8+
private: false;
9+
owner: User;
10+
html_url: string;
11+
description: string;
12+
fork: boolean;
13+
url: string;
14+
forks_url: string;
15+
keys_url: string;
16+
collaborators_url: string;
17+
teams_url: string;
18+
hooks_url: string;
19+
issue_events_url: string;
20+
events_url: string;
21+
assignees_url: string;
22+
branches_url: string;
23+
tags_url: string;
24+
blobs_url: string;
25+
git_tags_url: string;
26+
git_refs_url: string;
27+
trees_url: string;
28+
statuses_url: string;
29+
languages_url: string;
30+
stargazers_url: string;
31+
contributors_url: string;
32+
subscribers_url: string;
33+
subscription_url: string;
34+
commits_url: string;
35+
git_commits_url: string;
36+
comments_url: string;
37+
issue_comment_url: string;
38+
contents_url: string;
39+
compare_url: string;
40+
merges_url: string;
41+
archive_url: string;
42+
downloads_url: string;
43+
issues_url: string;
44+
pulls_url: string;
45+
milestones_url: string;
46+
notifications_url: string;
47+
labels_url: string;
48+
releases_url: string;
49+
deployments_url: string;
50+
created_at: string;
51+
updated_at: string;
52+
pushed_at: string;
53+
git_url: string;
54+
ssh_url: string;
55+
clone_url: string;
56+
svn_url: string;
57+
homepage: string;
58+
size: number;
59+
stargazers_count: number;
60+
watchers_count: number;
61+
language: string;
62+
has_issues: boolean;
63+
has_projects: boolean;
64+
has_downloads: boolean;
65+
has_wiki: boolean;
66+
has_pages: boolean;
67+
forks_count: number;
68+
mirror_url: string;
69+
archived: boolean;
70+
disabled: boolean;
71+
open_issues_count: number;
72+
license: {};
73+
forks: number;
74+
open_issues: number;
75+
watchers: number;
76+
default_branch: string;
77+
}
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export class User {
2+
login: string;
3+
id: number;
4+
node_id: string;
5+
avatar_url: string;
6+
gravatar_id: string;
7+
url: string;
8+
html_url: string;
9+
followers_url: string;
10+
following_url: string;
11+
gists_url: string;
12+
starred_url: string;
13+
subscriptions_url: string;
14+
organizations_url: string;
15+
repos_url: string;
16+
events_url: string;
17+
received_events_url: string;
18+
type: string;
19+
site_admin: boolean;
20+
name: string;
21+
company: string;
22+
blog: string;
23+
location: string;
24+
email: string;
25+
hireable: string;
26+
bio: string;
27+
public_repos: number;
28+
public_gists: number;
29+
followers: number;
30+
following: number;
31+
created_at: string;
32+
updated_at: string;
33+
}

src/app/pages/user-search/user-search.page.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</ion-buttons>
2323
</ion-item>
2424
</ion-list>
25-
<ion-card *ngFor="let repo of repoList$ | async; let index = index;">
25+
<ion-card *ngFor="let repo of repos$ | async; let index = index;">
2626
<ion-card-header> {{ repo.name }} </ion-card-header>
2727
<ion-card-content> {{ repo.description }} </ion-card-content>
2828
</ion-card>
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { GithubService } from "./../../services/github.service";
22
import { Component, OnInit } from "@angular/core";
33
import { Observable } from "rxjs";
4+
import { Repo } from "./models/repo";
45

56
@Component({
67
selector: "app-user-search",
@@ -10,15 +11,15 @@ import { Observable } from "rxjs";
1011
})
1112
export class UserSearchPage implements OnInit {
1213
results: Observable<any>;
13-
public repoList$;
14-
public username;
14+
public repos$: Observable<Repo[]>;
15+
public username: string;
1516

1617
constructor(private githubService: GithubService) {}
1718

1819
ngOnInit() {}
1920

2021
getRepos(): void {
21-
this.repoList$ = this.githubService.getRepos(this.username);
22-
console.log(this.repoList$.subscribe((x) => console.log(x)));
22+
this.repos$ = this.githubService.getRepos(this.username);
23+
console.log(this.repos$.subscribe((x) => console.log(x)));
2324
}
2425
}

0 commit comments

Comments
 (0)