45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
|
|
export interface TideData {
|
|
date: string;
|
|
highTide: { time: string; height: number };
|
|
lowTide: { time: string; height: number };
|
|
}
|
|
|
|
// Données de marées pour les 7 prochains jours
|
|
// En production, utiliser une API réelle comme https://www.tide-forecast.com/api
|
|
const generateTideData = (): TideData[] => {
|
|
const tides: TideData[] = [];
|
|
const today = new Date();
|
|
|
|
for (let i = 0; i < 7; i++) {
|
|
const date = new Date(today);
|
|
date.setDate(today.getDate() + i);
|
|
|
|
// Simulation de données de marées (à remplacer par une vraie API)
|
|
const dayOffset = i;
|
|
const highTideHour = (6 + dayOffset * 0.8) % 24;
|
|
const lowTideHour = (12 + dayOffset * 0.8) % 24;
|
|
|
|
tides.push({
|
|
date: date.toISOString().split("T")[0],
|
|
highTide: {
|
|
time: `${Math.floor(highTideHour).toString().padStart(2, "0")}:${Math.floor((highTideHour % 1) * 60).toString().padStart(2, "0")}`,
|
|
height: 1.2 + Math.random() * 0.3,
|
|
},
|
|
lowTide: {
|
|
time: `${Math.floor(lowTideHour).toString().padStart(2, "0")}:${Math.floor((lowTideHour % 1) * 60).toString().padStart(2, "0")}`,
|
|
height: 0.3 + Math.random() * 0.2,
|
|
},
|
|
});
|
|
}
|
|
|
|
return tides;
|
|
};
|
|
|
|
export async function GET() {
|
|
const tides = generateTideData();
|
|
return NextResponse.json(tides);
|
|
}
|
|
|