forked from BRETT/BRETT
Initial Commit
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
const bodySchema = z.object({
|
||||
name: z.string().trim().min(2).max(50).regex(/^[\w-]+$/, 'Nur Buchstaben, Zahlen, - und _'),
|
||||
})
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
await requirePermission(event, 'roles.manage')
|
||||
const { name } = await readValidatedBody(event, bodySchema.parse)
|
||||
const id = await ensureRole(name)
|
||||
return { id, name }
|
||||
})
|
||||
Reference in New Issue
Block a user