Spaces:
Build error
Build error
File size: 2,695 Bytes
333c51a 5cff373 333c51a 5cff373 333c51a 5cff373 333c51a 5cff373 333c51a 5cff373 333c51a 5cff373 333c51a 5cff373 333c51a 5cff373 333c51a 5cff373 333c51a 5cff373 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | import { NextRequest, NextResponse } from "next/server";
import { db } from "@/lib/db";
interface PlatformConfig {
name: string;
type: string;
fee: number;
adultContent: boolean;
legal: string;
}
const PLATFORM_CONFIGS: Record<string, PlatformConfig> = {
onlyfans: { name: "OnlyFans", type: "subscription", fee: 20, adultContent: true, legal: "Adult content permitido, verificar edad" },
patreon: { name: "Patreon", type: "subscription", fee: 12, adultContent: false, legal: "Restricciones en adult content" },
fansly: { name: "Fansly", type: "subscription", fee: 20, adultContent: true, legal: "Adult content permitido" },
fanvue: { name: "Fanvue", type: "subscription", fee: 15, adultContent: true, legal: "Adult content permitido" },
kofi: { name: "Ko-fi", type: "tips", fee: 0, adultContent: false, legal: "Sin adult content" },
instagram: { name: "Instagram", type: "free", fee: 0, adultContent: false, legal: "Sin desnudez" },
tiktok: { name: "TikTok", type: "free", fee: 0, adultContent: false, legal: "Contenido familiar" },
youtube: { name: "YouTube", type: "free", fee: 0, adultContent: false, legal: "Politicas de comunidad estrictas" }
};
export async function GET(request: NextRequest) {
try {
const { searchParams } = new URL(request.url);
const platform = searchParams.get("platform");
const userPlatforms = await db.monetizationPlatform.findMany({ where: { isActive: true } });
if (platform && PLATFORM_CONFIGS[platform]) {
return NextResponse.json({ success: true, platform: PLATFORM_CONFIGS[platform], userPlatforms });
}
return NextResponse.json({ success: true, platforms: PLATFORM_CONFIGS, userPlatforms });
} catch {
return NextResponse.json({ success: false, error: "Error" }, { status: 500 });
}
}
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const { platformName, accountId, accountName } = body;
const config = PLATFORM_CONFIGS[platformName];
if (!config) {
return NextResponse.json({ success: false, error: "Plataforma no valida" }, { status: 400 });
}
const platform = await db.monetizationPlatform.create({
data: {
name: config.name,
type: config.type,
accountId: accountId || null,
accountName: accountName || null,
feePercentage: config.fee,
legalTerms: JSON.stringify({ adultContent: config.adultContent, legal: config.legal }),
isActive: true,
isVerified: false
}
});
return NextResponse.json({ success: true, platform });
} catch {
return NextResponse.json({ success: false, error: "Error" }, { status: 500 });
}
} |