Repository: strapi/strapi
File: packages/core/admin/ee/server/src/index.ts (TypeScript)

Code before:
  };

  const isAIEnabled =
    strapi.config.get('admin.ai.enabled', true) && strapi.ee.features.isEnabled('cms-ai');

  const isAuditLogsEnabled =
    strapi.config.get('admin.auditLogs.enabled', true) &&
    strapi.ee.features.isEnabled('audit-logs');
  return {
    ...eeAdmin,
    controllers: {
      ...eeAdmin.controllers,
      ...(isAuditLogsEnabled ? { 'audit-logs': auditLogsController } : {}),
      ...(isAIEnabled ? { ai: aiController } : {}),
    },
    routes: {
      ...eeAdmin.routes,
      ...(isAuditLogsEnabled ? { 'audit-logs': auditLogsRoutes } : {}),
      ...(isAIEnabled ? { ai: aiRoutes } : {}),
    },
    async register({ strapi }: { strapi: Core.Strapi }) {
      // Run the the default registration
      await eeAdmin.register({ strapi });

      // Register internal ai service
      if (isAIEnabled) {
        strapi.add('ai', createAIService({ strapi }));
      }

      if (isAuditLogsEnabled) {
        // Register an internal audit logs service
        strapi.add('audit-logs', createAuditLogsService(strapi));
        // Register an internal audit logs lifecycle service
        const auditLogsLifecycle = createAuditLogsLifecycleService(strapi);
        strapi.add('audit-logs-lifecycle', auditLogsLifecycle);

        await auditLogsLifecycle.register();
      }
    },
    async destroy({ strapi }: { strapi: Core.Strapi }) {
      if (isAuditLogsEnabled) {
        strapi.get('audit-logs-lifecycle').destroy();
      }
      await eeAdmin.destroy({ strapi });
    },
  };
};

export default getAdminEE;


Review comment (suggestion):
I know `isAiEnabled` is in this file but seems a bit odd to me that this check is inside the `isAuditLogEnabled`...

Code after:
  };

  const isAIEnabled =
    strapi.config.get('admin.ai.enabled', true) && strapi.ee.features.isEnabled('cms-ai');

  const isAuditLogsEnabled =
    strapi.config.get('admin.auditLogs.enabled', true) &&
    strapi.ee.features.isEnabled('audit-logs');
  return {
    ...eeAdmin,
    controllers: {
      ...eeAdmin.controllers,
      ...(isAuditLogsEnabled ? { 'audit-logs': auditLogsController } : {}),
      ...(isAIEnabled ? { ai: aiController } : {}),
    },
    routes: {
      ...eeAdmin.routes,
      ...(isAuditLogsEnabled ? { 'audit-logs': auditLogsRoutes } : {}),
      ...(isAIEnabled ? { ai: aiRoutes } : {}),
    },
    async register({ strapi }: { strapi: Core.Strapi }) {
      // Run the the default registration
      await eeAdmin.register({ strapi });

      // Register internal ai service
      if (isAIEnabled) {
        strapi.add('ai', createAIContainer({ strapi }));
      }

      if (isAuditLogsEnabled) {
        // Register an internal audit logs service
        strapi.add('audit-logs', createAuditLogsService(strapi));
        // Register an internal audit logs lifecycle service
        const auditLogsLifecycle = createAuditLogsLifecycleService(strapi);
        strapi.add('audit-logs-lifecycle', auditLogsLifecycle);

        await auditLogsLifecycle.register();
      }
    },
    async destroy({ strapi }: { strapi: Core.Strapi }) {
      if (isAuditLogsEnabled) {
        strapi.get('audit-logs-lifecycle').destroy();
      }
      await eeAdmin.destroy({ strapi });
    },
  };
};

export default getAdminEE;