first commit
This commit is contained in:
44
app/api/tides/route.ts
Normal file
44
app/api/tides/route.ts
Normal file
@ -0,0 +1,44 @@
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user