Skip to content

Commit

Permalink
Minor cleanup in blueprints hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikermcneil committed Feb 5, 2016
1 parent d6efda0 commit 8eef18d
Showing 1 changed file with 25 additions and 45 deletions.
70 changes: 25 additions & 45 deletions lib/hooks/blueprints/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
};



/**
Expand Down Expand Up @@ -84,8 +85,6 @@ module.exports = function(sails) {





// Configuration of the blueprint actions themselves:

// Whether to populate all association attributes in the `find`
Expand All @@ -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,
}

},
Expand All @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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]);


Expand Down

0 comments on commit 8eef18d

Please sign in to comment.