Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion coverage/consts.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h1><a href="index.html">All files</a> consts.js</h1>
<div class="footer quiet pad2 space-top1 center small">
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2023-09-16T11:44:34.953Z
at 2023-09-19T10:01:15.058Z
</div>
<script src="prettify.js"></script>
<script>
Expand Down
102 changes: 51 additions & 51 deletions coverage/githubApi.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ <h1><a href="index.html">All files</a> githubApi.js</h1>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">4x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
Expand Down Expand Up @@ -209,10 +208,11 @@ <h1><a href="index.html">All files</a> githubApi.js</h1>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
Expand Down Expand Up @@ -242,26 +242,25 @@ <h1><a href="index.html">All files</a> githubApi.js</h1>
* @returns {Promise&lt;String[]&gt;} The github topics of a project
*/
export async function getGithubTopics(loginName, projectName, infoLog, isProd) {
if (infoLog) {
console.group("getGithubTopics");
}
if (loginName &amp;&amp; projectName) {
if (infoLog) {
console.group("getGithubTopics");
console.info("githubApi.ts: loginName: " + loginName);
console.info("githubApi.ts: projectName: " + projectName);
}
if (loginName &amp;&amp; projectName) {
if (infoLog) {
console.info("githubApi.ts: loginName: " + loginName);
console.info("githubApi.ts: projectName: " + projectName);
}
if (infoLog) {
console.groupEnd();
}
// https://www.npmjs.com/package/jsonpath MIT License
return Promise.resolve(jp.query(await returnData(loginName, projectName, infoLog, isProd), "$.topics[*]"));
if (infoLog) {
console.groupEnd();
}
else {
if (infoLog) {
console.groupEnd();
}
return Promise.resolve([]);
// https://www.npmjs.com/package/jsonpath MIT License
return Promise.resolve(jp.query(await returnData(loginName, projectName, infoLog, isProd), "$.topics[*]"));
} else {
if (infoLog) {
console.groupEnd();
}
return Promise.resolve([]);
}
}
/**
* Returns the github the project object / json of a project.
Expand All @@ -276,37 +275,38 @@ <h1><a href="index.html">All files</a> githubApi.js</h1>
* @returns {Promise&lt;any&gt;} The github the project object / json of a project
*/
async function returnData(loginName, projectName, infoLog, isProd) {
if (isProd) {
// get from github project api
const GITHUB_API_PROJECT_URL = GITHUB_API_BASE_URL + "repos/" + loginName + "/";
const response = await fetch(GITHUB_API_PROJECT_URL + projectName);
if (!response.ok) {
if (infoLog) {
console.info("API rate limit exceeded for nnn.nnn.nnn.nnn. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)");
console.info("https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting");
}
// Github has a Rate Limit
// in this case Status is 403 Forbidden
// and return this Message Object / Json:
// {
// message: "API rate limit exceeded for nnn.nnn.nnn.nnn. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
// documentation_url: 'https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting'
// }
}
return await response.json();
}
else {
// return mock data
// based on
// github-api/01-01-vanilla-HTML5-starter-page.json
return Promise.resolve({
name: "01-01-vanilla-HTML5-starter-page",
html_url: "https://github.com/roebi/01-01-vanilla-HTML5-starter-page",
description: "vanilla HTML 5 starter page - Have you ever heard of this HTML 5 tags ?",
homepage: "https://roebi.github.io/01-01-vanilla-HTML5-starter-page/",
topics: [" mockdata!", "html5", "html5-template", "roebi", "starter"],
});
if (isProd) {
// get from github project api
const GITHUB_API_PROJECT_URL = GITHUB_API_BASE_URL + "repos/" + loginName + "/";
const response = await fetch(GITHUB_API_PROJECT_URL + projectName);
if (!response.ok) {
if (infoLog) {
console.info(
"API rate limit exceeded for nnn.nnn.nnn.nnn. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
);
console.info("https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting");
}
// Github has a Rate Limit
// in this case Status is 403 Forbidden
// and return this Message Object / Json:
// {
// message: "API rate limit exceeded for nnn.nnn.nnn.nnn. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
// documentation_url: 'https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting'
// }
}
return await response.json();
} else {
// return mock data
// based on
// github-api/01-01-vanilla-HTML5-starter-page.json
return Promise.resolve({
name: "01-01-vanilla-HTML5-starter-page",
html_url: "https://github.com/roebi/01-01-vanilla-HTML5-starter-page",
description: "vanilla HTML 5 starter page - Have you ever heard of this HTML 5 tags ?",
homepage: "https://roebi.github.io/01-01-vanilla-HTML5-starter-page/",
topics: [" mockdata!", "html5", "html5-template", "roebi", "starter"],
});
}
}
&nbsp;</pre></td></tr></table></pre>

Expand All @@ -317,7 +317,7 @@ <h1><a href="index.html">All files</a> githubApi.js</h1>
<div class="footer quiet pad2 space-top1 center small">
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2023-09-16T11:44:34.953Z
at 2023-09-19T10:01:15.058Z
</div>
<script src="prettify.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ <h1>All files</h1>
<div class="footer quiet pad2 space-top1 center small">
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2023-09-16T11:44:34.953Z
at 2023-09-19T10:01:15.058Z
</div>
<script src="prettify.js"></script>
<script>
Expand Down
Loading