initial commit

This commit is contained in:
Owen Rees
2023-05-23 08:51:05 +02:00
parent 07837a54ee
commit 8b8bf9dcb6
9 changed files with 253 additions and 114 deletions
+13
View File
@@ -0,0 +1,13 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import clientPromise from "@/lib/mongodb";
export async function GET(req: NextApiRequest, res: NextApiResponse) {
try {
const client = await clientPromise
const db = client.db("tournamentsFranceDB")
const data = await db.collection("tournaments").find({}).toArray()
return new Response(JSON.stringify(data), { status: 200 })
} catch (error) {
return new Response(JSON.stringify(error), { status: 500 })
}
}