Initial commit: page-manager Next.js app with Coolify deploy support
Replace Vercel-specific infra (Cron, Blob) with self-hosted equivalents for deployment to Coolify: in-container cron scheduler (scripts/cron-runner.mjs) and disk-based upload storage served via /api/uploads/[...path]. Add Dockerfile, .dockerignore, and /api/health for container health checks. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib/db";
|
||||
import { actorLabel, requireSuperadmin } from "@/lib/auth/user";
|
||||
import { audit } from "@/lib/audit";
|
||||
|
||||
/** Facebook logins that can supply pages. Tokens never leave the server. */
|
||||
export async function GET() {
|
||||
const auth = await requireSuperadmin();
|
||||
if (!auth.ok) return auth.response;
|
||||
const connections = await prisma.metaConnection.findMany({
|
||||
select: { id: true, name: true, scopes: true, expiresAt: true, updatedAt: true, _count: { select: { pages: true } } },
|
||||
orderBy: { createdAt: "asc" },
|
||||
});
|
||||
return NextResponse.json({ connections, systemUser: Boolean(process.env.META_SYSTEM_USER_TOKEN) });
|
||||
}
|
||||
|
||||
/**
|
||||
* Forget a Facebook login. Pages already connected keep their own page tokens
|
||||
* and keep working; only re-listing pages from this login stops.
|
||||
*/
|
||||
export async function DELETE(req: Request) {
|
||||
const auth = await requireSuperadmin();
|
||||
if (!auth.ok) return auth.response;
|
||||
const id = new URL(req.url).searchParams.get("id") ?? "";
|
||||
const conn = await prisma.metaConnection.findUnique({ where: { id }, select: { name: true } });
|
||||
if (!conn) return NextResponse.json({ error: "ไม่พบการเชื่อมนี้" }, { status: 404 });
|
||||
await prisma.metaConnection.delete({ where: { id } });
|
||||
await audit({ action: "META_LOGIN_REMOVED", actorId: auth.user.id, actorLabel: actorLabel(auth.user), detail: { name: conn.name } });
|
||||
return NextResponse.json({ ok: true });
|
||||
}
|
||||
Reference in New Issue
Block a user