mirror of
https://github.com/detleph/server.git
synced 2026-09-05 16:06:21 +02:00
Extract function to create an object by name
+ Add route to create groups
This commit is contained in:
@@ -2,7 +2,7 @@ import { Admin } from "@prisma/client";
|
||||
import { PrismaClientUnknownRequestError } from "@prisma/client/runtime";
|
||||
import { Request, Response } from "express";
|
||||
import prisma from "../lib/prisma";
|
||||
import { generateError, genericError } from "./common";
|
||||
import { generateError, genericError, handleCreateByName } from "./common";
|
||||
|
||||
const basicGroup = {
|
||||
pid: true,
|
||||
@@ -103,3 +103,14 @@ export const getGroup = async (req: Request<GetGroupQueryParams>, res: Response)
|
||||
|
||||
return res.status(500).json(genericError);
|
||||
};
|
||||
|
||||
// at: POST /api/organisations/:eventPid/groups
|
||||
// requires: auth(ELEVATED)
|
||||
export const createGroup = async (req: Request<{ organisationPid: string }, {}, { name?: string }>, res: Response) => {
|
||||
return handleCreateByName(
|
||||
{ type: "group", data: { name: req.body.name, level: 1 } },
|
||||
{ type: "oragnisation", id: req.params.organisationPid },
|
||||
req,
|
||||
res
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user