move group routes to pro module

This commit is contained in:
Peter Clement 2022-07-20 15:28:20 +01:00
parent e239318ff6
commit 2c16089258
1 changed files with 0 additions and 37 deletions

View File

@ -1,37 +0,0 @@
import { groups } from "@budibase/pro"
import Router from "@koa/router"
import joiValidator from "../../../middleware/joi-validator"
import adminOnly from "../../../middleware/adminOnly"
import Joi from "joi"
const router = new Router()
function buildGroupSaveValidation() {
// prettier-ignore
return joiValidator.body(Joi.object({
_id: Joi.string().optional(),
_rev: Joi.string().optional(),
color: Joi.string().required(),
icon: Joi.string().required(),
name: Joi.string().required(),
role: Joi.string().optional(),
users: Joi.array().optional(),
apps: Joi.array().optional(),
roles: Joi.object().optional(),
createdAt: Joi.string().optional(),
updatedAt: Joi.string().optional(),
}).required())
}
router
.post(
"/api/global/groups",
adminOnly,
buildGroupSaveValidation(),
groups.save
)
.get("/api/global/groups", groups.fetch)
.delete("/api/global/groups/:id/:rev", adminOnly, groups.destroy)
.get("/api/global/groups/:id", adminOnly, groups.find)
module.exports = router