JustAPI Bot fix: comprehensive UI, docs, security, and deployment improvements · 7/14/2026
381467d
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
---
import { getDatabase, schema } from "@/db";
import BaseLayout from "@/layouts/BaseLayout.astro";
import { desc, eq, and, sql } from "drizzle-orm";
const db = getDatabase();
const currentUser = Astro.locals.user;
// Get filter from query params
const filter = Astro.url.searchParams.get("filter") || "open";
const sort = Astro.url.searchParams.get("sort") || "newest";
// Fetch issues from public repos, ordered by most recent
let issues: any[] = [];
try {
// Get issues with their repositories
const rawIssues = await db.query.issues.findMany({
where: filter === "closed"
? eq(schema.issues.state, "closed")
: filter === "all"
? undefined
: eq(schema.issues.state, "open"),
orderBy: sort === "oldest"
? [schema.issues.createdAt]
: sort === "comments"
? [desc(schema.issues.commentCount)]
: [desc(schema.issues.createdAt)],
limit: 50,
with: {
repository: {
with: {
owner: true,
},
},
author: true,
},
});
// Filter to only public repos
issues = rawIssues.filter(issue =>
issue.repository?.visibility === "public"
);
} catch (e) {
console.error("Error fetching issues:", e);
}
function timeAgo(date: string | number | Date) {
if (!date) return "";
const seconds = Math.floor(
(new Date().getTime() - new Date(date).getTime()) / 1000
);
if (seconds < 60) return "just now";
if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`;
if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ago`;
if (seconds < 604800) return `${Math.floor(seconds / 86400)}d ago`;
return new Date(date).toLocaleDateString();
}
---
<BaseLayout title="Issues - OpenCodeHub">
<div class="container py-8 max-w-5xl">
<!-- Header -->
<div class="flex items-center justify-between mb-8">
<div>
<h1 class="text-3xl font-bold text-foreground flex items-center gap-3">
<div class="p-2 rounded-lg bg-gradient-to-br from-green-500/20 to-emerald-500/20 border border-green-500/30">
<svg class="h-7 w-7 text-green-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
</div>
Issues
</h1>
<p class="text-muted-foreground mt-2">Browse issues across all public repositories</p>
</div>
</div>
<!-- Filters -->
<div class="relative mb-6">
<div class="absolute -inset-[1px] bg-gradient-to-r from-green-500/20 via-transparent to-emerald-500/20 rounded-xl opacity-50"></div>
<div class="relative rounded-xl border border-border bg-card/80 backdrop-blur-sm p-4">
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
<!-- Filter Tabs -->
<div class="flex items-center gap-1">
<a
href="/issues?filter=open"
class:list={[
"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all",
filter === "open"
? "bg-green-500/20 text-green-400 border border-green-500/30"
: "text-muted-foreground hover:bg-accent"
]}
>
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
Open
</a>
<a
href="/issues?filter=closed"
class:list={[
"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all",
filter === "closed"
? "bg-purple-500/20 text-purple-400 border border-purple-500/30"
: "text-muted-foreground hover:bg-accent"
]}
>
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
Closed
</a>
<a
href="/issues?filter=all"
class:list={[
"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all",
filter === "all"
? "bg-cyan-500/20 text-cyan-400 border border-cyan-500/30"
: "text-muted-foreground hover:bg-accent"
]}
>
All
</a>
</div>
<!-- Sort -->
<div class="flex items-center gap-2">
<span class="text-sm text-muted-foreground">Sort:</span>
<select
id="sort-select"
class="rounded-lg border border-border bg-secondary px-3 py-1.5 text-sm text-muted-foreground focus:outline-none focus:border-green-500/50"
>
<option value="newest" selected={sort === "newest"}>Newest</option>
<option value="oldest" selected={sort === "oldest"}>Oldest</option>
<option value="comments" selected={sort === "comments"}>Most commented</option>
</select>
</div>
</div>
</div>
</div>
<!-- Issues List -->
<div class="relative">
<div class="absolute -inset-[1px] bg-gradient-to-r from-green-500/20 via-transparent to-emerald-500/20 rounded-xl opacity-50"></div>
<div class="relative rounded-xl border border-border bg-card/80 backdrop-blur-sm overflow-hidden">
{issues.length > 0 ? (
<div class="divide-y divide-white/5">
{issues.map((issue) => (
<a
href={`/${issue.repository?.owner?.username}/${issue.repository?.name}/issues/${issue.number}`}
class="block p-4 hover:bg-accent/50 transition-colors group"
>
<div class="flex items-start gap-3">
<!-- Status Icon -->
<div class:list={[
"p-2 rounded-lg mt-0.5",
issue.state === "open"
? "bg-green-500/10 text-green-400"
: "bg-purple-500/10 text-purple-400"
]}>
{issue.state === "open" ? (
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
) : (
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
)}
</div>
<div class="flex-1 min-w-0">
<!-- Title & Repo -->
<div class="flex items-center gap-2 mb-1">
<span class="text-xs text-muted-foreground font-medium">
{issue.repository?.owner?.username}/{issue.repository?.name}
</span>
<span class="text-muted-foreground">#{issue.number}</span>
</div>
<h3 class="font-semibold text-foreground group-hover:text-green-400 transition-colors truncate">
{issue.title}
</h3>
<!-- Meta -->
<div class="flex items-center gap-3 mt-2 text-xs text-muted-foreground">
<span>
opened {timeAgo(issue.createdAt)} by {issue.author?.username || "unknown"}
</span>
{(issue.commentCount || 0) > 0 && (
<span class="flex items-center gap-1">
<svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"></path>
</svg>
{issue.commentCount}
</span>
)}
</div>
</div>
<!-- Avatar -->
<div class="hidden sm:block">
{issue.author?.avatarUrl ? (
<img
src={issue.author.avatarUrl}
alt={issue.author.username}
class="w-8 h-8 rounded-full ring-2 ring-border"
/>
) : (
<div class="w-8 h-8 rounded-full bg-gradient-to-br from-green-400 to-emerald-600 flex items-center justify-center text-xs font-bold text-foreground ring-2 ring-border">
{issue.author?.username?.[0]?.toUpperCase() || "?"}
</div>
)}
</div>
</div>
</a>
))}
</div>
) : (
<div class="text-center py-16">
<div class="relative inline-block mb-4">
<svg class="h-16 w-16 text-green-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
<div class="absolute inset-0 bg-green-500 blur-2xl opacity-20"></div>
</div>
<h3 class="text-lg font-semibold text-foreground mb-2">No issues found</h3>
<p class="text-muted-foreground">
{filter === "open"
? "All issues are closed! 🎉"
: filter === "closed"
? "No closed issues yet."
: "No issues have been created yet."}
</p>
</div>
)}
</div>
</div>
</div>
</BaseLayout>
<script>
const sortSelect = document.getElementById("sort-select") as HTMLSelectElement;
sortSelect?.addEventListener("change", () => {
const url = new URL(window.location.href);
url.searchParams.set("sort", sortSelect.value);
window.location.href = url.toString();
});
</script>