This repository has been archived by the owner on Nov 21, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 362
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
48d9e23
commit 2bcdbf0
Showing
34 changed files
with
1,727 additions
and
1,080 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 |
---|---|---|
|
@@ -16,3 +16,4 @@ Thumbs.db | |
public/js/main-compiled.js | ||
public/js/main-compiled.js.map | ||
build/ | ||
api/build |
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,2 @@ | ||
# Ignore artifacts: | ||
api/build |
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,14 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 2020, | ||
sourceType: 'module', | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
extends: ['plugin:@typescript-eslint/recommended'], | ||
rules: { | ||
'@typescript-eslint/ban-ts-comment': 'off', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
const statusCodes: { | ||
[key: string]: number; | ||
} = { | ||
notUser: 400, | ||
}; | ||
|
||
const errorDescriptions: { | ||
[key: string]: string; | ||
} = { | ||
notUser: 'Username must belong to a user account.', | ||
}; | ||
|
||
export const getStatusCode = (error: string) => statusCodes[error] || 400; | ||
|
||
export const getErrorDescription = (error: string) => | ||
errorDescriptions[error] || | ||
"Couldn't find any data or we hit an error, err try again?"; |
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
import { Octokit } from '@octokit/rest'; | ||
import { RestEndpointMethodTypes } from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types'; | ||
import getPageLinks from './getPageLinks'; | ||
import hasNextPage from './hasNextPage'; | ||
|
||
const getNextPage = async ( | ||
response: RestEndpointMethodTypes['search']['issuesAndPullRequests']['response'], | ||
github: Octokit, | ||
pullRequestData: RestEndpointMethodTypes['search']['issuesAndPullRequests']['response']['data']['items'] | ||
) => { | ||
try { | ||
const baseUrl = process.env.GITHUB_API_BASE_URL | ||
? process.env.GITHUB_API_BASE_URL | ||
: 'https://api.github.com'; | ||
const nextPageLink = await getPageLinks(response).next.replace(baseUrl, ''); | ||
|
||
const githubResults = (await github.request( | ||
'GET ' + nextPageLink | ||
)) as RestEndpointMethodTypes['search']['issuesAndPullRequests']['response']; | ||
const newPullRequestData = pullRequestData.concat(githubResults.data.items); | ||
if (hasNextPage(githubResults)) { | ||
return await getNextPage(githubResults, github, newPullRequestData); | ||
} | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
console.log(`Found ${pullRequestData.length} pull requests.`); | ||
} | ||
return newPullRequestData; | ||
} catch (error: unknown) { | ||
console.log('Error: ' + error); | ||
return error; | ||
} | ||
}; | ||
|
||
export default getNextPage; |
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
export interface GetPageLinksLink { | ||
link?: string; | ||
headers?: { | ||
link?: string; | ||
}; | ||
} | ||
|
||
interface HasNextPage { | ||
next?: string; | ||
} | ||
|
||
const getPageLinks = (link: GetPageLinksLink): HasNextPage => { | ||
const extractedLink: string = link.link || link.headers.link || ''; | ||
|
||
const links: { | ||
[key: string]: string[]; | ||
} = {}; | ||
|
||
// link format: | ||
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"' | ||
extractedLink.replace( | ||
/<([^>]*)>;\s*rel="([\w]*)"/g, | ||
// @ts-ignore | ||
(m: string, uri: string[], type: string) => { | ||
links[type] = uri; | ||
} | ||
); | ||
|
||
return links; | ||
}; | ||
|
||
export default getPageLinks; |
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
import getPageLinks, { GetPageLinksLink } from './getPageLinks'; | ||
|
||
const hasNextPage = (link: GetPageLinksLink) => { | ||
return getPageLinks(link).next; | ||
}; | ||
|
||
export default hasNextPage; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.