Mutual Highlighting (#41) (#55)

* Mutual Highlighting (#41)

* Tidy up

* Delete unused API route
This commit is contained in:
Timothy Armes
2023-07-05 13:55:56 +02:00
committed by GitHub
parent 96fda01929
commit 1715b1646b
18 changed files with 451 additions and 272 deletions
-29
View File
@@ -1,29 +0,0 @@
import clientPromise from "@/lib/mongodb";
import { dateOrderingFrance } from "@/utils/dbDateOrdering";
import { errorLog } from "@/utils/logger";
/**
* Tournament data API endpoint
* @route /api/v1/tournaments/france
* @public
*/
export const revalidate = 3600; // revalidate cache every 6 hours
export async function GET() {
const headers = {
"Content-Type": "application/json",
};
try {
const client = await clientPromise;
const db = client.db("tournamentsFranceDB");
const results = await dateOrderingFrance(db);
const data = results.map(({ _id, ...rest }) => ({
id: _id,
...rest,
}));
return new Response(JSON.stringify(data), { status: 200, headers });
} catch (error) {
errorLog(error);
return new Response(JSON.stringify(error), { status: 500, headers });
}
}