-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c628ef
commit 64c6aa3
Showing
5 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import SocialNetwork, { SocialNetworks } from "@lib/user/SocialNetwork"; | ||
/** | ||
* Some static information. | ||
*/ | ||
|
||
export const GITHUB_URL = "https://api.github.com/users/renantatsuo"; | ||
|
||
export const SOCIAL_NETWORKS: SocialNetwork[] = [ | ||
{ | ||
name: SocialNetworks.GITHUB, | ||
url: "https://github.com/renantatsuo", | ||
}, | ||
{ | ||
name: SocialNetworks.CODEPEN, | ||
url: "https://codepen.io/renantatsuo", | ||
}, | ||
{ | ||
name: SocialNetworks.TWITTER, | ||
url: "https://twitter.com/renantatsuo", | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
type GithubUser = { | ||
login: string; | ||
id: number; | ||
avatar_url: string; | ||
gravatar_id: string; | ||
url: string; | ||
html_url: string; | ||
followers_url: string; | ||
following_url: string; | ||
gists_url: string; | ||
starred_url: string; | ||
subscriptions_url: string; | ||
organizations_url: string; | ||
repos_url: string; | ||
events_url: string; | ||
received_events_url: string; | ||
type: string; | ||
site_admin: boolean; | ||
}; | ||
|
||
export default GithubUser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export enum SocialNetworks { | ||
TWITTER = "twitter", | ||
GITHUB = "github", | ||
CODEPEN = "codepen", | ||
} | ||
|
||
type SocialNetwork = { | ||
name: SocialNetworks; | ||
url: string; | ||
}; | ||
|
||
export default SocialNetwork; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import SocialNetwork from "./SocialNetwork"; | ||
|
||
type User = { | ||
username: string; | ||
avatar: string; | ||
social: SocialNetwork[]; | ||
}; | ||
|
||
export default User; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Http from "@lib/http/Http"; | ||
import { GITHUB_URL, SOCIAL_NETWORKS } from "@lib/static"; | ||
import { container } from "tsyringe"; | ||
import "../AppContainer"; | ||
import GithubUser from "./GithubUser"; | ||
import SocialNetwork from "./SocialNetwork"; | ||
import User from "./User"; | ||
|
||
const http: Http = container.resolve("Http"); | ||
|
||
export async function getUser(): Promise<User> { | ||
const user: GithubUser = await http.execute<GithubUser>(GITHUB_URL); | ||
const socialNetworks: SocialNetwork[] = SOCIAL_NETWORKS; | ||
|
||
return { | ||
avatar: user.avatar_url, | ||
username: user.login, | ||
social: socialNetworks, | ||
}; | ||
} |