-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
218 lines (186 loc) Β· 5.85 KB
/
index.html
File metadata and controls
218 lines (186 loc) Β· 5.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>GitHub API Backend v3.0 - Tester</title>
<style>
:root {
--bg: #1e1e2f;
--text: #eaeaea;
--accent: #00b7ff;
--success: #4caf50;
--error: #ff4d4f;
--input-bg: #2b2b3d;
--border: #444;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 2rem;
background: var(--bg);
color: var(--text);
font-family: 'Segoe UI', Roboto, sans-serif;
line-height: 1.6;
}
h1, h2 {
color: var(--accent);
}
form {
display: flex;
flex-direction: column;
gap: 1rem;
max-width: 600px;
margin-bottom: 2rem;
background: #262636;
padding: 1.5rem;
border-radius: 10px;
}
label {
font-weight: 500;
}
input {
width: 100%;
padding: 0.7rem;
border: 1px solid var(--border);
border-radius: 5px;
background: var(--input-bg);
color: var(--text);
font-size: 1rem;
}
button {
padding: 0.75rem 1.2rem;
background-color: var(--accent);
color: white;
border: none;
font-size: 1rem;
font-weight: bold;
cursor: pointer;
border-radius: 6px;
transition: background 0.2s ease;
}
button:hover {
background-color: #0099cc;
}
#result {
white-space: pre-wrap;
background: #121217;
padding: 1rem;
border-radius: 8px;
border-left: 4px solid transparent;
overflow-x: auto;
font-family: monospace;
font-size: 0.95rem;
color: #eaeaea;
}
.success {
border-color: var(--success);
}
.error {
border-color: var(--error);
color: var(--error);
}
@media (max-width: 600px) {
body {
padding: 1rem;
}
form {
padding: 1rem;
}
input, button {
font-size: 1rem;
}
}
</style>
</head>
<body>
<h1>π GitHub API Backend v3.0</h1>
<p>Test your GitHub API proxy and stats endpoints:</p>
<form id="api-form">
<label for="endpoint">GitHub API Endpoint:</label>
<input type="text" id="endpoint" value="/users/octocat" placeholder="/users/username or /repos/owner/repo" />
<label for="username">GitHub Username (for stats):</label>
<input type="text" id="username" value="amitxd75" placeholder="Enter GitHub username" />
<div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
<button type="submit" style="flex: 1;">π Test Both</button>
<button type="button" onclick="testEndpoint()" style="flex: 1; background: #6366f1;">π‘ Endpoint Only</button>
<button type="button" onclick="testStats()" style="flex: 1; background: #10b981;">π Stats Only</button>
</div>
</form>
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;">
<h2>π¦ Results</h2>
<button onclick="clearResults()" style="padding: 0.5rem 1rem; font-size: 0.9rem; background: #6b7280;">Clear</button>
</div>
<div id="result">Ready to test! Enter a GitHub username and endpoint above.</div>
<script>
const resultDiv = document.getElementById('result');
function setLoading() {
resultDiv.textContent = "β³ Loading...";
resultDiv.className = "";
}
function setResult(content, isSuccess = true) {
resultDiv.textContent = content;
resultDiv.className = isSuccess ? 'success' : 'error';
}
function clearResults() {
resultDiv.textContent = "Ready to test! Enter a GitHub username and endpoint above.";
resultDiv.className = "";
}
async function testEndpoint() {
const endpoint = document.getElementById('endpoint').value.trim();
if (!endpoint) {
setResult("β Please enter an endpoint", false);
return;
}
setLoading();
try {
const res = await fetch(`/api/github/v2/?endpoint=${encodeURIComponent(endpoint)}`);
const data = await res.json();
setResult(`π‘ Endpoint: ${endpoint}\n\n${JSON.stringify(data, null, 2)}`, res.ok);
} catch (err) {
setResult(`β Error: ${err.message}`, false);
}
}
async function testStats() {
const username = document.getElementById('username').value.trim();
if (!username) {
setResult("β Please enter a username", false);
return;
}
setLoading();
try {
const res = await fetch(`/api/github/v2/stats?username=${encodeURIComponent(username)}`);
const data = await res.json();
setResult(`π Stats for: ${username}\n\n${JSON.stringify(data, null, 2)}`, res.ok);
} catch (err) {
setResult(`β Error: ${err.message}`, false);
}
}
document.getElementById('api-form').onsubmit = async (e) => {
e.preventDefault();
const endpoint = document.getElementById('endpoint').value.trim();
const username = document.getElementById('username').value.trim();
if (!endpoint || !username) {
setResult("β Please enter both endpoint and username", false);
return;
}
setLoading();
try {
const [proxyRes, statsRes] = await Promise.all([
fetch(`/api/github/v2/?endpoint=${encodeURIComponent(endpoint)}`),
fetch(`/api/github/v2/stats?username=${encodeURIComponent(username)}`)
]);
const proxyData = await proxyRes.json();
const statsData = await statsRes.json();
const output = `π‘ Endpoint: ${endpoint}\n\n${JSON.stringify(proxyData, null, 2)}\n\n` +
`π Stats for: ${username}\n\n${JSON.stringify(statsData, null, 2)}`;
setResult(output, proxyRes.ok && statsRes.ok);
} catch (err) {
setResult(`β Error: ${err.message}`, false);
}
};
</script>
</body>
</html>