v0.7.0 — Suggestions module via @otm/account-panel
Wire the shared Gitea-backed suggestions panel: page, list/create + comments + upload API routes, sidebar link. Suggestions file as issues on bonna61/Moonbase; screenshot uploads persist via a mounted volume. Mirrors the FMB wiring. Secrets (NEXTAUTH_SECRET, GITEA_TOKEN) moved out of docker-compose.yml to an interpolated gitignored .env on the host, per CLAUDE.md (never commit the token). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
20
src/lib/suggestions.ts
Normal file
20
src/lib/suggestions.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { NextRequest } from "next/server";
|
||||
import type { GiteaConfig } from "@otm/account-panel";
|
||||
import { getSession } from "./auth";
|
||||
|
||||
// Suggestions are filed as issues on the Gitea repo — no DB model.
|
||||
// Returns null (→ routes answer 503, panel shows a tidy empty state) when any
|
||||
// piece is missing, so the feature degrades gracefully if env isn't wired.
|
||||
export function giteaConfig(): GiteaConfig | null {
|
||||
const baseUrl = process.env.GITEA_URL;
|
||||
const token = process.env.GITEA_TOKEN;
|
||||
const repo = process.env.GITEA_REPO;
|
||||
if (!baseUrl || !token || !repo) return null;
|
||||
return { baseUrl, token, repo };
|
||||
}
|
||||
|
||||
/** Only signed-in users may read/write suggestions. */
|
||||
export async function suggestionGuard(_req: NextRequest): Promise<boolean> {
|
||||
const session = await getSession();
|
||||
return !!session?.user;
|
||||
}
|
||||
Reference in New Issue
Block a user