first commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { z } from 'zod';
|
||||
|
||||
const GenerateSchema = z.object({
|
||||
destination: z.string().min(2),
|
||||
startDate: z.string(),
|
||||
numDays: z.number().int().min(1).max(14),
|
||||
budget: z.number().positive(),
|
||||
currency: z.string(),
|
||||
experienceMode: z.string(),
|
||||
preferences: z.array(z.string()),
|
||||
});
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
try {
|
||||
const body = await req.json();
|
||||
const data = GenerateSchema.parse(body);
|
||||
|
||||
// Stub response (Phase 3 will replace with real Geoapify + LLM)
|
||||
const days = Array.from({ length: data.numDays }, (_, i) => ({
|
||||
day: i + 1,
|
||||
activities: [
|
||||
{
|
||||
time: '09:30',
|
||||
title: `Highlight ${i + 1} (${data.experienceMode})`,
|
||||
type: data.experienceMode === 'foodie' ? 'restaurant' : 'attraction',
|
||||
cost: Math.round(data.budget / (data.numDays * 3)),
|
||||
},
|
||||
{
|
||||
time: '13:30',
|
||||
title: 'Recommended meal',
|
||||
type: 'restaurant',
|
||||
cost: 22,
|
||||
},
|
||||
],
|
||||
}));
|
||||
|
||||
return NextResponse.json({
|
||||
tripId: 'trip_' + Date.now(),
|
||||
destination: data.destination,
|
||||
numDays: data.numDays,
|
||||
experienceMode: data.experienceMode,
|
||||
summary: `Stub plan for ${data.destination} — ${data.numDays} days in ${data.experienceMode} mode.`,
|
||||
days,
|
||||
estimatedCost: Math.round(data.budget * 0.82),
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return NextResponse.json({ error: 'Invalid input' }, { status: 400 });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export async function GET() {
|
||||
const envCheck = {
|
||||
hasGeoapify: !!process.env.GEOAPIFY_API_KEY,
|
||||
hasTicketmaster: !!process.env.TICKETMASTER_API_KEY,
|
||||
hasLLM: !!process.env.LLM_API_KEY,
|
||||
hasDb: !!process.env.DATABASE_URL,
|
||||
};
|
||||
|
||||
return NextResponse.json({
|
||||
status: 'ok',
|
||||
env: envCheck,
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user