title: Sails js: How can I use service method in policy
body: <p>I am using sails v0.10. I made a service inside the /service/Utility.js and I want to use the Ulitity.js method inside the /policies/addWhere.js
  I want to know is it possible to use service in policy.</p>
  
  <p>My Utility.js is looks like:</p>
  
  <pre><code>var util = require('util'),
        _ = require('lodash');
  
  module.exports = {
  
    getRequestAction: function (req) {
      if (req.options.action) return req.options.action;
  
      var controller = req.options.controller || req.options.model;
  
      var baseRoute = sails.config.blueprints.prefix + controller;
      var requestRoute = req.route.method + ' ' + req.route.path;
  
      var Model = sails.models[controller];
  
      if (req.options.shortcuts &amp;&amp; Model) {
        var shortcutRoutes = {
          '/%s/find/:id?': 'find',
          '/%s/create': 'create',
          '/%s/update/:id?': 'update',
          '/%s/destroy/:id?': 'destroy'
        };
  
        var shortcutAction = _.findWhere(shortcutRoutes, function(blueprint, pattern){
          var shortcutRoute = util.format(pattern, baseRoute);
          return req.route.path === shortcutRoute;
        });
  
        if (shortcutAction) return shortcutAction;
      }
  
      if (req.options.rest &amp;&amp; Model) {
        var restRoutes = {
          'get /%s/:id?': 'find',
          'post /%s': 'create',
          'put /%s/:id?': 'update',
          'delete /%s/:id?': 'destroy'
        };
  
        var restAction =_.findWhere(restRoutes, function(blueprint, pattern){
          var restRoute = util.format(pattern, baseRoute);
          return requestRoute === restRoute;
        });
  
        if (restAction) return restAction;
  
        var associationActions = _.compact(_.map(req.options.associations, function(association){
          var alias = association.alias;
  
          var associationRoutes = {
            'get /%s/:parentid/%s/:id?': 'populate',
            'post /%s/:parentid/%s': 'add',
            'delete /%s/:parentid/%s': 'remove'
          };
  
          return _.findWhere(associationRoutes, function(blueprint, pattern){
            var associationRoute = util.format(pattern, baseRoute, alias);
            return requestRoute === associationRoute;
          });
        }));
  
        if (associationActions.length &gt; 0) return associationActions[0];
      }
    }
  };
  </code></pre>
  
  <p>And the addWhere.js is like:</p>
  
  <pre><code> var Utility=require('util');
    module.exports = function(req, res, next) {
        var action = Utility.getRequestAction(req);
        console.log("Request action is", action);
      }
        next();
    };
  </code></pre>
  
  <p>But when I tried to execute it ,returns the error:</p>
  
  <pre><code>error: Sending 500 ("Server Error") response: 
   TypeError: Object #&lt;Object&gt; has no method 'getRequestAction'
      at module.exports (/var/www/sails/LayupSailsServer/api/policies/addWhere.js:7:26)
      at routeTargetFnWrapper (/var/www/sails/LayupSailsServer/node_modules/sails/lib/router/bind.js:178:5)
      at callbacks (/var/www/sails/LayupSailsServer/node_modules/sails/node_modules/express/lib/router/index.js:164:37)
      at param (/var/www/sails/LayupSailsServer/node_modules/sails/node_modules/express/lib/router/index.js:138:11)
      at pass (/var/www/sails/LayupSailsServer/node_modules/sails/node_modules/express/lib/router/index.js:145:5)
      at nextRoute (/var/www/sails/LayupSailsServer/node_modules/sails/node_modules/express/lib/router/index.js:100:7)
      at callbacks (/var/www/sails/LayupSailsServer/node_modules/sails/node_modules/express/lib/router/index.js:167:11)
      at /var/www/sails/LayupSailsServer/node_modules/sails/lib/router/bind.js:186:7
      at module.exports (/var/www/sails/LayupSailsServer/api/policies/isAuthorized.js:6:5)
      at routeTargetFnWrapper (/var/www/sails/LayupSailsServer/node_modules/sails/lib/router/bind.js:178:5) [TypeError: Object #&lt;Object&gt; has no method 'getRequestAction']
  </code></pre>
  
  <p>I want to know what's the wrong am doing.</p>