Skip to content

Commit

Permalink
fix: correct http return and invalid styling (ryo-ma#269)
Browse files Browse the repository at this point in the history
* fix: correct http return and invalid styling

Page responded with incorrect http return message.

* fix: correct http return and invalid styling

Update error_page.ts
  • Loading branch information
gabriel-logan authored May 22, 2024
1 parent f85b88a commit a50a8b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function app(req: Request): Promise<Response> {
<p>Enter your username and click get trophies</p>
<form action="https://github-profile-trophy.vercel.app/" method="get">
<label for="username">GitHub Username</label>
<input type="text" name="username" id="username" placeholder="Ex. mojombo" required>
<input type="text" name="username" id="username" placeholder="Ex. gabriel-logan" required>
<button type="submit">Get Trophy&apos;s</button>
</form>
</div>
Expand Down Expand Up @@ -117,7 +117,7 @@ async function app(req: Request): Promise<Response> {
const userResponseInfo = await client.requestUserInfo(username);
if (userResponseInfo instanceof ServiceError) {
return new Response(
ErrorPage({ error: userInfo, username }).render(),
ErrorPage({ error: userResponseInfo, username }).render(),
{
status: userResponseInfo.code,
headers: new Headers({ "Content-Type": "text" }),
Expand Down
18 changes: 15 additions & 3 deletions src/error_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ abstract class BaseError {
p {
color: #666;
}
#back-link {
display: flex;
justify-content: center;
text-decoration: none;
}
#back-link:hover {
text-decoration: underline;
}
section {
width: 80%;
margin: 0 auto;
Expand Down Expand Up @@ -62,7 +70,7 @@ abstract class BaseError {
cursor: pointer;
}
#base-show {
font-size: 14px;
font-size: 16px;
color: #333;
background-color: #f4f4f4;
padding: 10px;
Expand All @@ -75,12 +83,12 @@ abstract class BaseError {
}
@media (max-width: 768px) {
#base-show {
font-size: 14;
font-size: 14px;
}
}
@media (max-width: 480px) {
#base-show {
font-size: 8;
font-size: 8px;
}
}
@media (min-width: 768px) {
Expand All @@ -98,6 +106,10 @@ abstract class BaseError {
<body>
<h1 style="text-align: center;">${this.status} - ${this.message}</h1>
<p style="text-align: center;">${this.content ?? ""}</p>
${
this.content &&
'<a id="back-link" href="https://github-profile-trophy.vercel.app/">Go back</a>'
}
</body>
</html>`;

Expand Down

0 comments on commit a50a8b7

Please sign in to comment.