mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
chore: split routes into files
This commit is contained in:
parent
66a2bba78e
commit
80c272dd9e
43
packages/core/admin/ee/server/routes/audit-logs.js
Normal file
43
packages/core/admin/ee/server/routes/audit-logs.js
Normal file
@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
const { enableFeatureMiddleware } = require('./utils');
|
||||
|
||||
module.exports = {
|
||||
type: 'admin',
|
||||
routes: [
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/audit-logs',
|
||||
handler: 'auditLogs.findMany',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('audit-logs')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::audit-logs.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/audit-logs/:id',
|
||||
handler: 'auditLogs.findOne',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('audit-logs')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::audit-logs.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
@ -1,229 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const { features } = require('@strapi/strapi/lib/utils/ee');
|
||||
|
||||
const enableFeatureMiddleware = (featureName) => (ctx, next) => {
|
||||
if (features.isEnabled(featureName)) {
|
||||
return next();
|
||||
}
|
||||
|
||||
ctx.status = 404;
|
||||
module.exports = {
|
||||
sso: require('./sso'),
|
||||
'license-limit': require('./license-limit'),
|
||||
'audit-logs': require('./audit-logs'),
|
||||
'review-workflows': require('./review-workflows'),
|
||||
};
|
||||
|
||||
module.exports = [
|
||||
// SSO
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/providers',
|
||||
handler: 'authentication.getProviders',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('sso')],
|
||||
auth: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/connect/:provider',
|
||||
handler: 'authentication.providerLogin',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('sso')],
|
||||
auth: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'POST',
|
||||
path: '/connect/:provider',
|
||||
handler: 'authentication.providerLogin',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('sso')],
|
||||
auth: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/providers/options',
|
||||
handler: 'authentication.getProviderLoginOptions',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('sso')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{ name: 'admin::hasPermissions', config: { actions: ['admin::provider-login.read'] } },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'PUT',
|
||||
path: '/providers/options',
|
||||
handler: 'authentication.updateProviderLoginOptions',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('sso')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{ name: 'admin::hasPermissions', config: { actions: ['admin::provider-login.update'] } },
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
// Audit logs
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/audit-logs',
|
||||
handler: 'auditLogs.findMany',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('audit-logs')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::audit-logs.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/audit-logs/:id',
|
||||
handler: 'auditLogs.findOne',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('audit-logs')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::audit-logs.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
// License limit infos
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/license-limit-information',
|
||||
handler: 'admin.licenseLimitInformation',
|
||||
config: {
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: [
|
||||
'admin::users.create',
|
||||
'admin::users.read',
|
||||
'admin::users.update',
|
||||
'admin::users.delete',
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
// Review workflow
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/review-workflows/workflows',
|
||||
handler: 'workflows.find',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('review-workflows')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::review-workflows.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/review-workflows/workflows/:id',
|
||||
handler: 'workflows.findById',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('review-workflows')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::review-workflows.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/review-workflows/workflows/:workflow_id/stages',
|
||||
handler: 'stages.find',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('review-workflows')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::review-workflows.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'PUT',
|
||||
path: '/review-workflows/workflows/:workflow_id/stages',
|
||||
handler: 'stages.replace',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('review-workflows')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::review-workflows.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/review-workflows/workflows/:workflow_id/stages/:id',
|
||||
handler: 'stages.findById',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('review-workflows')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::review-workflows.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'PUT',
|
||||
path: '/content-manager/(collection|single)-types/:model_uid/:id/stage',
|
||||
handler: 'stages.updateEntity',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('review-workflows')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::review-workflows.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
29
packages/core/admin/ee/server/routes/license-limit.js
Normal file
29
packages/core/admin/ee/server/routes/license-limit.js
Normal file
@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
type: 'admin',
|
||||
routes: [
|
||||
// License limit infos
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/license-limit-information',
|
||||
handler: 'admin.licenseLimitInformation',
|
||||
config: {
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: [
|
||||
'admin::users.create',
|
||||
'admin::users.read',
|
||||
'admin::users.update',
|
||||
'admin::users.delete',
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
112
packages/core/admin/ee/server/routes/review-workflows.js
Normal file
112
packages/core/admin/ee/server/routes/review-workflows.js
Normal file
@ -0,0 +1,112 @@
|
||||
'use strict';
|
||||
|
||||
const { enableFeatureMiddleware } = require('./utils');
|
||||
|
||||
module.exports = {
|
||||
type: 'admin',
|
||||
routes: [
|
||||
// Review workflow
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/review-workflows/workflows',
|
||||
handler: 'workflows.find',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('review-workflows')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::review-workflows.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/review-workflows/workflows/:id',
|
||||
handler: 'workflows.findById',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('review-workflows')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::review-workflows.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/review-workflows/workflows/:workflow_id/stages',
|
||||
handler: 'stages.find',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('review-workflows')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::review-workflows.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'PUT',
|
||||
path: '/review-workflows/workflows/:workflow_id/stages',
|
||||
handler: 'stages.replace',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('review-workflows')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::review-workflows.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/review-workflows/workflows/:workflow_id/stages/:id',
|
||||
handler: 'stages.findById',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('review-workflows')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::review-workflows.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'PUT',
|
||||
path: '/content-manager/(collection|single)-types/:model_uid/:id/stage',
|
||||
handler: 'stages.updateEntity',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('review-workflows')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{
|
||||
name: 'admin::hasPermissions',
|
||||
config: {
|
||||
actions: ['admin::review-workflows.read'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
60
packages/core/admin/ee/server/routes/sso.js
Normal file
60
packages/core/admin/ee/server/routes/sso.js
Normal file
@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
const { enableFeatureMiddleware } = require('./utils');
|
||||
|
||||
module.exports = {
|
||||
type: 'admin',
|
||||
routes: [
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/providers',
|
||||
handler: 'authentication.getProviders',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('sso')],
|
||||
auth: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/connect/:provider',
|
||||
handler: 'authentication.providerLogin',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('sso')],
|
||||
auth: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'POST',
|
||||
path: '/connect/:provider',
|
||||
handler: 'authentication.providerLogin',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('sso')],
|
||||
auth: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/providers/options',
|
||||
handler: 'authentication.getProviderLoginOptions',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('sso')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{ name: 'admin::hasPermissions', config: { actions: ['admin::provider-login.read'] } },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'PUT',
|
||||
path: '/providers/options',
|
||||
handler: 'authentication.updateProviderLoginOptions',
|
||||
config: {
|
||||
middlewares: [enableFeatureMiddleware('sso')],
|
||||
policies: [
|
||||
'admin::isAuthenticatedAdmin',
|
||||
{ name: 'admin::hasPermissions', config: { actions: ['admin::provider-login.update'] } },
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user