import { NextResponse } from 'next/server' import { readRestaurants, writeRestaurants } from '@/app/lib/restaurants' import { Restaurant } from '@/app/types' export async function GET() { const restaurants = readRestaurants() return NextResponse.json(restaurants) } export async function POST(request: Request) { const body = await request.json() as Omit const restaurants = readRestaurants() const newRestaurant: Restaurant = { ...body, id: crypto.randomUUID(), visits: [], } restaurants.push(newRestaurant) writeRestaurants(restaurants) return NextResponse.json(newRestaurant, { status: 201 }) }