2021-09-07 14:51:48 +02:00
|
|
|
'use strict';
|
|
|
|
|
2025-07-28 12:02:09 +01:00
|
|
|
const { UsersPermissionsRouteValidator } = require('./validation');
|
|
|
|
|
|
|
|
module.exports = (strapi) => {
|
|
|
|
const validator = new UsersPermissionsRouteValidator(strapi);
|
|
|
|
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
method: 'GET',
|
|
|
|
path: '/roles/:id',
|
|
|
|
handler: 'role.findOne',
|
|
|
|
request: {
|
|
|
|
params: {
|
|
|
|
id: validator.roleIdParam,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
response: validator.roleResponseSchema,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
method: 'GET',
|
|
|
|
path: '/roles',
|
|
|
|
handler: 'role.find',
|
|
|
|
response: validator.rolesResponseSchema,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
method: 'POST',
|
|
|
|
path: '/roles',
|
|
|
|
handler: 'role.createRole',
|
|
|
|
request: {
|
|
|
|
body: { 'application/json': validator.createRoleBodySchema },
|
|
|
|
},
|
|
|
|
response: validator.roleSuccessResponseSchema,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
method: 'PUT',
|
|
|
|
path: '/roles/:role',
|
|
|
|
handler: 'role.updateRole',
|
|
|
|
request: {
|
|
|
|
params: {
|
|
|
|
role: validator.roleIdParam,
|
|
|
|
},
|
|
|
|
body: { 'application/json': validator.updateRoleBodySchema },
|
|
|
|
},
|
|
|
|
response: validator.roleSuccessResponseSchema,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
method: 'DELETE',
|
|
|
|
path: '/roles/:role',
|
|
|
|
handler: 'role.deleteRole',
|
|
|
|
request: {
|
|
|
|
params: {
|
|
|
|
role: validator.roleIdParam,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
response: validator.roleSuccessResponseSchema,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
};
|