apps/web: Next.js 16 (App Router), Tailwind 4 and shadcn/ui, light and dark from the system. Pages render on the server and call the API with Eden Treaty (typed by @t5de/api), forwarding the visitor's cookie; forms use server actions; sign-up, sign-in and sign-out use Better Auth's React client. /api is rewritten to the API so its cookies are first-party. Who's online follows the API's event stream (Next's gzip is off: it held the stream back). Standalone output with a Dockerfile; deploys to Vercel as is. Co-Authored-By: Claude Opus 5.5 <[email protected]>
23 lines
736 B
TypeScript
23 lines
736 B
TypeScript
import { notFound, redirect } from "next/navigation";
|
|
import { NavLink } from "@/components/header-client";
|
|
import { getMe, isModerator, type Person } from "@/lib/api";
|
|
|
|
/** The signed-in moderator, or off to sign in; others get not found (the console isn't for them). */
|
|
export async function requireModerator(path: string): Promise<Person> {
|
|
const me = await getMe();
|
|
if (!me) redirect(`/signin?next=${encodeURIComponent(path)}`);
|
|
if (!isModerator(me)) notFound();
|
|
return me;
|
|
}
|
|
|
|
export function ConsoleNav() {
|
|
return (
|
|
<nav className="mb-8 flex gap-1 border-b pb-3 text-sm">
|
|
<NavLink href="/console" exact>
|
|
Overview
|
|
</NavLink>
|
|
<NavLink href="/console/people">People</NavLink>
|
|
</nav>
|
|
);
|
|
}
|