Skip to content

Commit f091474

Browse files
committed
Added db/api ping on home page
added ping and fixed some compatibility issues for older ios
1 parent 8fb73ff commit f091474

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="UTF-8" />
66
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
77
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8-
<title>Ryan's Portfolio</title>
8+
<title>Ryan's Website</title>
99
</head>
1010
<body>
1111
<div id="root"></div>

src/pages/Home.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@ import { Github, Linkedin, Mail, ArrowDown } from 'lucide-react';
22
import ExperienceCard from '../components/ExperienceCard';
33
import SkillBadge from '../components/SkillBadge';
44
import Header from '../components/Header';
5+
import { useEffect } from "react";
56

67
function Home() {
8+
// ping to warm up API and DB
9+
useEffect(() => {
10+
fetch("https://ryan-website-api.onrender.com/api/db/ping", {
11+
method: "GET",
12+
cache: "no-store",
13+
}).catch(() => {});
14+
}, []);
15+
716
return (
817
<div className="bg-gray-900">
918
<Header />

src/pages/SignIn.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { setAuth } from "../utils/auth";
55

66
export default function SignIn() {
77
const API_BASE = "https://ryan-website-api.onrender.com";
8-
const USERNAME_RE = /^(?![._-])(?!.*[._-]{2})[a-z0-9._-]+(?<![._-])$/;
8+
9+
const USERNAME_RE = /^(?![._-])(?!.*[._-]{2})(?!.*[._-]\s*$)[A-Za-z0-9._-]+(?:\s*)$/;
910
const PASSWORD_RE = /^[\x21-\x7E]+$/;
1011

1112
type SignInResponse = { access_token: string; token_type: string; expires_at: number; role: string };
@@ -111,6 +112,7 @@ export default function SignIn() {
111112
onChange={(e) => setPassword(e.target.value)}
112113
onBlur={() => setTouched(t => ({ ...t, password: true }))}
113114
className="w-full rounded-xl bg-gray-900 text-gray-100 border border-gray-700 focus:border-blue-500 focus:ring-2 focus:ring-blue-500/40 px-4 py-3 pr-12"
115+
placeholder="password"
114116
/>
115117
<button type="button" onClick={() => setShowPw(s => !s)}
116118
className="absolute inset-y-0 right-3 my-auto p-2 text-gray-400 hover:text-gray-200">

src/pages/SignUp.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ import { setAuth } from "../utils/auth";
55

66
export default function SignUp() {
77
const API_BASE = "https://ryan-website-api.onrender.com";
8-
const USERNAME_RE = /^(?![._-])(?!.*[._-]{2})[a-z0-9._-]+(?<![._-])$/;
8+
9+
const USERNAME_RE = /^(?![._-])(?!.*[._-]{2})(?!.*[._-]\s*$)[A-Za-z0-9._-]+(?:\s*)$/;
910
const PASSWORD_RE = /^[\x21-\x7E]+$/;
11+
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
12+
1013

1114
type SignUpResponse = { ok: boolean; message: string; access_token: string; token_type: string; expires_at: number; role: string };
1215
type ApiError = { detail?: string; message?: string };
@@ -27,8 +30,8 @@ export default function SignUp() {
2730
null;
2831

2932
const emailError =
30-
(touched.email && (!email || email.length === 0)) ? "Email is required." :
31-
(email && (!email.includes("@") || !email.split("@")[1]?.includes("."))) ? "Invalid email format." :
33+
(touched.email && !email) ? "Email is required." :
34+
(email && !EMAIL_RE.test(email)) ? "Invalid email format." :
3235
null;
3336

3437
const passwordError =

0 commit comments

Comments
 (0)