mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-07-23 04:26:57 +00:00
api data transformation
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
- map and table mounts in tournament page <- get data to send to map/table
|
- map and table mounts in tournament page <- get data to send to map/table
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
//TODO SRP for web and API data fetching
|
//TODO SRP for web and API data fetching
|
||||||
//TODO API should not display __v and _id should just be id
|
|
||||||
//TODO about page
|
//TODO about page
|
||||||
//TODO contact page needs working mailer
|
//TODO contact page needs working mailer
|
||||||
//TODO font size on mobile screen
|
//TODO font size on mobile screen
|
||||||
|
|||||||
@@ -15,7 +15,11 @@ export async function GET() {
|
|||||||
const client = await clientPromise;
|
const client = await clientPromise;
|
||||||
const db = client.db("tournamentsFranceDB");
|
const db = client.db("tournamentsFranceDB");
|
||||||
|
|
||||||
const data = await dateOrderingFrance(db);
|
const results = await dateOrderingFrance(db);
|
||||||
|
const data = results.map(({ _id, __v, ...rest }) => ({
|
||||||
|
id: _id,
|
||||||
|
...rest,
|
||||||
|
}));
|
||||||
|
|
||||||
return new Response(JSON.stringify(data), { status: 200, headers });
|
return new Response(JSON.stringify(data), { status: 200, headers });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { Db } from "mongodb";
|
|||||||
/**
|
/**
|
||||||
* Converts date from string into a date to allow ordering
|
* Converts date from string into a date to allow ordering
|
||||||
*/
|
*/
|
||||||
// TODO remove the .toArray method as this is not SRP friendly
|
|
||||||
export const dateOrderingFrance = async (db: Db) => {
|
export const dateOrderingFrance = async (db: Db) => {
|
||||||
return await db
|
return await db
|
||||||
.collection("tournaments")
|
.collection("tournaments")
|
||||||
|
|||||||
Reference in New Issue
Block a user