Skip to content
Open
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
44 changes: 1 addition & 43 deletions api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,49 +44,7 @@ async function app(req: Request): Promise<Response> {
const themeParam: string = params.getStringValue("theme", "default");
if (username === null) {
const [base] = req.url.split("?");
const error = new Error400(
`<section>
<div>
<h2>"username" is a required query parameter</h2>
<p>The URL should look like
<div>
<p id="base-show">${base}?username=USERNAME</p>
<button>Copy Base Url</button>
<span id="temporary-span"></span>
</div>where
<code>USERNAME</code> is <em>your GitHub username.</em>
</div>
<div>
<h2>You can use this form: </h2>
<p>Enter your username and click "Get Trophies"</p>
<form action="${base}" method="get">
<label for="username">GitHub Username</label>
<input type="text" name="username" id="username" placeholder="Ex. gabriel-logan" required>
<label for="theme">Theme (Optional)</label>
<input type="text" name="theme" id="theme" placeholder="Ex. onedark" value="light">
<text>
See all the available themes
<a href="https://github.com/ryo-ma/github-profile-trophy?tab=readme-ov-file#apply-theme" target="_blank">here</a>
</text>
<br>
<button type="submit">Get Trophies</button>
</form>
</div>
<script>
const button = document.querySelector("button");
const input = document.querySelector("input");
const temporarySpan = document.querySelector("#temporary-span");

button.addEventListener("click", () => {
navigator.clipboard.writeText(document.querySelector("#base-show").textContent);
temporarySpan.textContent = "Copied!";
setTimeout(() => {
temporarySpan.textContent = "";
}, 1500);
});
</script>
</section>`,
);
const error = new Error400(base);
return new Response(
error.render(),
{
Expand Down
9 changes: 8 additions & 1 deletion src/Services/GithubApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ export class GithubApiService extends GithubRepository {
pullRequest.status,
];

if (status.includes("rejected")) {
const values = [
repository.status === "fulfilled" ? repository.value : null,
activity.status === "fulfilled" ? activity.value : null,
issue.status === "fulfilled" ? issue.value : null,
pullRequest.status === "fulfilled" ? pullRequest.value : null,
];

if (status.includes("rejected") || values.some((v) => v instanceof ServiceError)) {
Logger.error(`Can not find a user with username:' ${username}'`);
return new ServiceError("Not found", EServiceKindError.NOT_FOUND);
}
Expand Down
Loading
Loading