pages
This commit is contained in:
parent
ee267bf62a
commit
e0df9ed858
11 changed files with 206 additions and 35 deletions
15
pages/api/games.ts
Normal file
15
pages/api/games.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import client from "../../lib/mongodb"
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const db = client.db("SloppyFuckers")
|
||||
switch (req.method) {
|
||||
case "POST":
|
||||
const myEvent = await db.collection("games").insertOne(JSON.parse(req.body))
|
||||
res.json(myEvent)
|
||||
break
|
||||
case "GET":
|
||||
const allEvents = await db.collection("games").find({}).toArray()
|
||||
res.json({ status: 200, data: allEvents })
|
||||
break
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue