File size: 802 Bytes
7200823
c6b6c96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e73dea2
c6b6c96
 
 
 
 
 
 
 
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
import { NextResponse } from 'next/server'
import { createCampaign, isTorqueConfigured } from '@/lib/torque-mcp'

export async function POST(req: Request) {
  const body = await req.json()

  if (!body.name || !body.type || !body.budget) {
    return NextResponse.json({ error: 'name, type, and budget required' }, { status: 400 })
  }

  const result = await createCampaign(body)

  if (!result.success) {
    const status = isTorqueConfigured() ? 502 : 503
    return NextResponse.json({ success: false, error: result.error }, { status })
  }

  return NextResponse.json({ success: true, campaignId: result.campaignId, platformUrl: result.platformUrl })
}

export async function GET() {
  return NextResponse.json({
    status: isTorqueConfigured() ? 'ok' : 'unconfigured',
    campaigns: [],
  })
}