mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-06-28 22:54:14 +00:00
feat: banner and report viewer in admin panel
This commit is contained in:
parent
419fcb4788
commit
a8c83b9cb6
6 changed files with 206 additions and 27 deletions
30
src/app/api/admin/banner/route.ts
Normal file
30
src/app/api/admin/banner/route.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { auth } from "@/lib/auth";
|
||||
|
||||
let bannerText: string | null = null;
|
||||
|
||||
export async function GET() {
|
||||
return NextResponse.json({ success: true, message: bannerText });
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const session = await auth();
|
||||
if (!session) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
|
||||
if (Number(session.user.id) !== Number(process.env.NEXT_PUBLIC_ADMIN_USER_ID)) return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
||||
|
||||
const body = await request.text();
|
||||
bannerText = body;
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
}
|
||||
|
||||
export async function DELETE() {
|
||||
const session = await auth();
|
||||
if (!session) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
|
||||
if (Number(session.user.id) !== Number(process.env.NEXT_PUBLIC_ADMIN_USER_ID)) return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
||||
|
||||
bannerText = null;
|
||||
return NextResponse.json({ success: true });
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue