From 8eef18d0a5303f01e855c347c31f9288a22b5d62 Mon Sep 17 00:00:00 2001 From: Mike McNeil Date: Fri, 5 Feb 2016 03:45:46 -0600 Subject: [PATCH] Minor cleanup in blueprints hook. --- lib/hooks/blueprints/index.js | 70 +++++++++++++---------------------- 1 file changed, 25 insertions(+), 45 deletions(-) diff --git a/lib/hooks/blueprints/index.js b/lib/hooks/blueprints/index.js index d27f4e5a62..b57149743e 100644 --- a/lib/hooks/blueprints/index.js +++ b/lib/hooks/blueprints/index.js @@ -2,20 +2,21 @@ * Module dependencies */ -var _ = require('lodash') - , util = require('util') - , pluralize = require('pluralize') - , BlueprintController = { - create : require('./actions/create') - , find : require('./actions/find') - , findone : require('./actions/findOne') - , update : require('./actions/update') - , destroy : require('./actions/destroy') - , populate: require('./actions/populate') - , add : require('./actions/add') - , remove : require('./actions/remove') - } - , STRINGFILE = require('sails-stringfile'); +var _ = require('lodash'); +var util = require('util'); +var pluralize = require('pluralize'); +var STRINGFILE = require('sails-stringfile'); +var BlueprintController = { + create: require('./actions/create'), + find: require('./actions/find'), + findone: require('./actions/findOne'), + update: require('./actions/update'), + destroy: require('./actions/destroy'), + populate: require('./actions/populate'), + add: require('./actions/add'), + remove: require('./actions/remove'), +}; + /** @@ -84,8 +85,6 @@ module.exports = function(sails) { - - // Configuration of the blueprint actions themselves: // Whether to populate all association attributes in the `find` @@ -95,16 +94,8 @@ module.exports = function(sails) { // Whether to run `Model.watch()` in the `find` blueprint action. autoWatch: true, - - // (TODO: generated comments for jsonp configuration needs to be updated w/ new options) - // (TODO: need to mention new `req.options` stuff in generated comments) - - // // Enable JSONP callbacks. + // Enable JSONP callbacks. // jsonp: false - - // Deprecated: - // Skip blueprint if `:id?` is NOT an integer. - // expectIntegerId: false, } }, @@ -121,18 +112,6 @@ module.exports = function(sails) { // Provide hook context to closures hook = this; - //////////////////////////////////////////////////////////////////////// - // TODO: - // Provide deprecation notice letting 0.9 users know that they need to - // move their blueprint configuration to `config.blueprints` instead of - // `config.controllers.blueprints`. Similarly, need a message to let - // folks know to move their controller-specific blueprint config from - // `SomeController._config.blueprints` to `SomeController._config`. - // In both cases, we can "fix" the configuration in-memory, avoiding - // allowing the app to "still work". This can be done the same way we're - // doing it for adapter config. - //////////////////////////////////////////////////////////////////////// - // Register route syntax for binding blueprints directly. sails.on('route:typeUnknown', onRoute); @@ -168,11 +147,11 @@ module.exports = function(sails) { bindShadowRoutes: function() { var logWarns = function(warns) { - sails.log.blank(); - _.each(warns, function (warn) { - sails.log.warn(warn); - }); - STRINGFILE.logMoreInfoLink(STRINGFILE.get('links.docs.config.blueprints'), sails.log.warn); + sails.log.blank(); + _.each(warns, function (warn) { + sails.log.warn(warn); + }); + STRINGFILE.logMoreInfoLink(STRINGFILE.get('links.docs.config.blueprints'), sails.log.warn); }; _.each(sails.middleware.controllers, function eachController (controller, controllerId) { @@ -235,9 +214,10 @@ module.exports = function(sails) { } // Determine the names of the controller's user-defined actions - // IMPORTANT: Use `sails.controllers` instead of `sails.middleware.controllers` - // (since `sails.middleware.controllers` will have blueprints already mixed-in, - // and we want the explicit actions defined in the app) + // IMPORTANT: Note that we use `sails.controllers` rather than + // `sails.middleware.controllers` (since `sails.middleware.controllers` + // will have blueprints already mixed-in, and we want the explicit actions + // defined in the app) var actions = Object.keys(sails.controllers[controllerId]);