import { NextRequest, NextResponse } from 'next/server'

const API = process.env.LEGAL_SERVICE_URL ?? 'http://localhost:3200'

export async function GET() {
  const res = await fetch(`${API}/email/settings`, { cache: 'no-store' })
  return NextResponse.json(await res.json(), { status: res.status })
}

export async function PUT(req: NextRequest) {
  const body = await req.json()
  const res = await fetch(`${API}/email/settings`, {
    method: 'PUT',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(body),
  })
  return NextResponse.json(await res.json(), { status: res.status })
}
