Implemented server routes

This commit is contained in:
Sebastian Seedorf
2022-08-17 23:27:19 +02:00
parent 9660f0cf34
commit 92b762bbd2
27 changed files with 2754 additions and 1692 deletions

View File

@@ -1,12 +1,14 @@
import {NextApiHandler} from "next";
import {GroupData, setGroups} from "../../src/database/groups";
import {nextHandler} from "../../src/utils/errors";
import {waitForInitSchemas} from "../../src/validation/schemas";
const handler: NextApiHandler = async (req, res) => {
const handler = nextHandler(async (req, res) => {
if (req.method !== 'POST') throw new Error('Invalid method')
await waitForInitSchemas.resolve()
const data = req.body as GroupData
const uuid = await setGroups(data)
res.json({ uuid })
}
})
export default handler