Initial commit

This commit is contained in:
JetSprow
2026-04-29 05:12:39 +10:00
commit 27dbca9cbf
379 changed files with 43486 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
import { NextResponse } from "next/server";
import { generateSubscriptionContent } from "@/services/subscription";
import { prisma } from "@/lib/prisma";
export async function GET(
req: Request,
{ params }: { params: Promise<{ id: string }> }
) {
const { id } = await params;
const url = new URL(req.url);
const token = url.searchParams.get("token");
if (!token) {
return NextResponse.json({ error: "Missing token" }, { status: 401 });
}
const sub = await prisma.userSubscription.findUnique({
where: { id },
});
if (!sub || sub.downloadToken !== token) {
return NextResponse.json({ error: "Invalid token" }, { status: 401 });
}
if (sub.status !== "ACTIVE") {
return NextResponse.json({ error: "Subscription inactive" }, { status: 403 });
}
const content = await generateSubscriptionContent(id);
return new Response(content, {
headers: {
"Content-Type": "text/plain; charset=utf-8",
"Content-Disposition": `attachment; filename="jboard-sub.txt"`,
},
});
}