mirror of
https://github.com/tiennm99/llmapikey.git
synced 2026-06-17 12:48:54 +00:00
refactor: simplify comments, styling, and conflict-resolution control flow
- replace stale plan-reference comments with intent-describing ones - move inline nav style to a .site-nav CSS class - drop dummy placeholder return in generate-key resolveConflict
This commit is contained in:
@@ -76,8 +76,10 @@ export async function generateKey() {
|
||||
* Resolve a reserve() conflict: existing active key, reclaimable stale pending,
|
||||
* or an in-progress request.
|
||||
*
|
||||
* Returns either a fresh reservation id to mint against, or a terminal result.
|
||||
*
|
||||
* @param {{ githubUserId: string, githubUsername: string }} identity
|
||||
* @returns {Promise<{ reclaimedId?: string, result: GenerateKeyResult }>}
|
||||
* @returns {Promise<{ reclaimedId?: string, result?: GenerateKeyResult }>}
|
||||
*/
|
||||
async function resolveConflict(identity) {
|
||||
const row = await repo.findByGithubUserId(identity.githubUserId);
|
||||
@@ -88,7 +90,7 @@ async function resolveConflict(identity) {
|
||||
if (row && isStale(row.created_at, STALE_PENDING_MS)) {
|
||||
await repo.deletePending(row.id);
|
||||
const retryId = await repo.reserve(identity.githubUserId, identity.githubUsername);
|
||||
if (retryId) return { reclaimedId: retryId, result: { status: "error" } };
|
||||
if (retryId) return { reclaimedId: retryId };
|
||||
}
|
||||
return {
|
||||
result: { status: "error", message: "A key request is already in progress. Try again shortly." },
|
||||
|
||||
@@ -52,6 +52,12 @@ header.site-header {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.site-nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.panel {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ export const metadata = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Root layout. The session-aware header is added in Phase 3.
|
||||
* Root layout wrapping every page with the session-aware site header.
|
||||
*
|
||||
* @param {{ children: React.ReactNode }} props
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ export async function SiteHeader() {
|
||||
<Link href="/" className="brand">
|
||||
llmapikey
|
||||
</Link>
|
||||
<nav style={{ display: "flex", gap: "1rem", alignItems: "center" }}>
|
||||
<nav className="site-nav">
|
||||
<Link href="/docs">Docs</Link>
|
||||
{username ? (
|
||||
<>
|
||||
|
||||
@@ -5,8 +5,8 @@ import { cookies } from "next/headers";
|
||||
|
||||
/**
|
||||
* Cookie-based Supabase client (anon key) for reading/refreshing the auth
|
||||
* session on the server. Use this to know WHO the request is (Phase 3 identity),
|
||||
* never to touch `api_keys` — that table lives in the unexposed `llmapikey`
|
||||
* session on the server. Use this to know WHO the request is, never to touch
|
||||
* `api_keys` — that table lives in the unexposed `llmapikey`
|
||||
* schema and is reached only via the direct Postgres client (lib/db).
|
||||
*
|
||||
* In Server Components cookie writes throw; we swallow that — session refresh
|
||||
|
||||
Reference in New Issue
Block a user