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

@@ -0,0 +1,16 @@
import {nextHandler} from "../../../../../src/utils/errors";
import {validate} from "../../../../../src/validation";
import {GroupIdParam} from "../../../../../src/types/ApiSchemas";
import {removeGroup} from "../../../../../src/database/groups";
import {waitForInitSchemas} from "../../../../../src/validation/schemas";
const handler = nextHandler(async (req, res) => {
if (req.method !== 'POST') throw new Error('Invalid method')
await waitForInitSchemas.resolve()
const { transformed: params } = validate<GroupIdParam>(req.query, '/GroupIdParam')
const success = await removeGroup(params.id, params.name)
res.json({ success })
})
export default handler