31 lines
904 B
JavaScript
31 lines
904 B
JavaScript
import { NextResponse } from 'next/server';
|
|
|
|
const TRIP_SERVICE_URL = 'http://trip-service.ai-agents.svc.cluster.local:6002';
|
|
|
|
export async function PUT(req, { params }) {
|
|
try {
|
|
const body = await req.json();
|
|
const res = await fetch(`${TRIP_SERVICE_URL}/trips/${params.id}`, {
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(body)
|
|
});
|
|
const data = await res.json();
|
|
return NextResponse.json(data);
|
|
} catch (error) {
|
|
return NextResponse.json({ error: error.message }, { status: 500 });
|
|
}
|
|
}
|
|
|
|
export async function DELETE(req, { params }) {
|
|
try {
|
|
const res = await fetch(`${TRIP_SERVICE_URL}/trips/${params.id}`, {
|
|
method: 'DELETE'
|
|
});
|
|
const data = await res.json();
|
|
return NextResponse.json(data);
|
|
} catch (error) {
|
|
return NextResponse.json({ error: error.message }, { status: 500 });
|
|
}
|
|
}
|