|
|
@@ -11,13 +11,6 @@ module.exports = function(sails) { |
|
|
var buildDictionary = require('sails-build-dictionary');
|
|
|
|
|
|
|
|
|
// TODO:
|
|
|
// Look at improving `includeAll` to work asynchronously
|
|
|
// CommonJS `require` is a blocking operation, and makes apps
|
|
|
// start slower.
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Module loader
|
|
|
*
|
|
|
@@ -70,27 +63,9 @@ module.exports = function(sails) { |
|
|
|
|
|
// Server-Side Code
|
|
|
//
|
|
|
// For `controllers` hook
|
|
|
controllers: path.resolve(config.appPath, 'api/controllers'),
|
|
|
// For `policies` hook
|
|
|
policies: path.resolve(config.appPath, 'api/policies'),
|
|
|
// For `services` hook
|
|
|
services: path.resolve(config.appPath, 'api/services'),
|
|
|
// For `orm` hook
|
|
|
adapters: path.resolve(config.appPath, 'api/adapters'),
|
|
|
models: path.resolve(config.appPath, 'api/models'),
|
|
|
// For `userhooks` hook
|
|
|
hooks: path.resolve(config.appPath, 'api/hooks'),
|
|
|
// For `blueprints` hook
|
|
|
blueprints: path.resolve(config.appPath, 'api/blueprints'),
|
|
|
// For `responses` hook
|
|
|
responses: path.resolve(config.appPath, 'api/responses'),
|
|
|
|
|
|
// Server-Side HTML
|
|
|
//
|
|
|
// For `views` hook
|
|
|
views: path.resolve(config.appPath, 'views'),
|
|
|
layout: path.resolve(config.appPath, 'views/layout.ejs'),
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
@@ -125,27 +100,9 @@ module.exports = function(sails) { |
|
|
|
|
|
// Server-Side Code
|
|
|
//
|
|
|
// For `controllers` hook
|
|
|
controllers: path.resolve(sails.config.appPath, sails.config.paths.controllers),
|
|
|
// For `policies` hook
|
|
|
policies: path.resolve(sails.config.appPath, sails.config.paths.policies),
|
|
|
// For `services` hook
|
|
|
services: path.resolve(sails.config.appPath, sails.config.paths.services),
|
|
|
// For `orm` hook
|
|
|
adapters: path.resolve(sails.config.appPath, sails.config.paths.adapters),
|
|
|
models: path.resolve(sails.config.appPath, sails.config.paths.models),
|
|
|
// For `userhooks` hook
|
|
|
hooks: path.resolve(sails.config.appPath, sails.config.paths.hooks),
|
|
|
// For `blueprints` hook
|
|
|
blueprints: path.resolve(sails.config.appPath, sails.config.paths.blueprints),
|
|
|
// For `responses` hook
|
|
|
responses: path.resolve(sails.config.appPath, sails.config.paths.responses),
|
|
|
|
|
|
// Server-Side HTML
|
|
|
//
|
|
|
// For `views` hook
|
|
|
views: path.resolve(sails.config.appPath, sails.config.paths.views),
|
|
|
layout: path.resolve(sails.config.appPath, sails.config.paths.layout)
|
|
|
models: path.resolve(sails.config.appPath, sails.config.paths.models)
|
|
|
});
|
|
|
},
|
|
|
|
|
|
@@ -213,24 +170,6 @@ module.exports = function(sails) { |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Load app controllers
|
|
|
*
|
|
|
* @param {Object} options
|
|
|
* @param {Function} cb
|
|
|
*/
|
|
|
loadControllers: function (cb) {
|
|
|
buildDictionary.optional({
|
|
|
dirname: sails.config.paths.controllers,
|
|
|
filter: /(.+)Controller\.(js|coffee|litcoffee)$/,
|
|
|
flattenDirectories: true,
|
|
|
keepDirectoryPath: true,
|
|
|
replaceExpr: /Controller/
|
|
|
}, cb);
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Load adapters
|
|
|
@@ -281,109 +220,6 @@ module.exports = function(sails) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Load app services
|
|
|
*
|
|
|
* @param {Object} options
|
|
|
* @param {Function} cb
|
|
|
*/
|
|
|
loadServices: function (cb) {
|
|
|
buildDictionary.optional({
|
|
|
dirname : sails.config.paths.services,
|
|
|
filter : /(.+)\.(js|coffee|litcoffee)$/,
|
|
|
depth : 1,
|
|
|
caseSensitive : true
|
|
|
}, cb);
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Check for the existence of views in the app
|
|
|
*
|
|
|
* @param {Object} options
|
|
|
* @param {Function} cb
|
|
|
*/
|
|
|
statViews: function (cb) {
|
|
|
buildDictionary.optional({
|
|
|
dirname: sails.config.paths.views,
|
|
|
filter: /(.+)\..+$/,
|
|
|
replaceExpr: null,
|
|
|
dontLoad: true
|
|
|
}, cb);
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Load app policies
|
|
|
*
|
|
|
* @param {Object} options
|
|
|
* @param {Function} cb
|
|
|
*/
|
|
|
loadPolicies: function (cb) {
|
|
|
buildDictionary.optional({
|
|
|
dirname: sails.config.paths.policies,
|
|
|
filter: /(.+)\.(js|coffee|litcoffee)$/,
|
|
|
replaceExpr: null,
|
|
|
flattenDirectories: true,
|
|
|
keepDirectoryPath: true
|
|
|
}, cb);
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Load app hooks
|
|
|
*
|
|
|
* @param {Object} options
|
|
|
* @param {Function} cb
|
|
|
*/
|
|
|
loadUserHooks: function (cb) {
|
|
|
buildDictionary.optional({
|
|
|
dirname: sails.config.paths.hooks,
|
|
|
filter: /^(.+)\.(js|coffee|litcoffee)$/,
|
|
|
|
|
|
// Hooks should be defined as either single files as a function
|
|
|
// OR (better yet) a subfolder with an index.js file
|
|
|
// (like a standard node module)
|
|
|
depth: 2
|
|
|
}, cb);
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Load app blueprint middleware.
|
|
|
*
|
|
|
* @param {Object} options
|
|
|
* @param {Function} cb
|
|
|
*/
|
|
|
loadBlueprints: function (cb) {
|
|
|
buildDictionary.optional({
|
|
|
dirname: sails.config.paths.blueprints,
|
|
|
filter: /(.+)\.(js|coffee|litcoffee)$/,
|
|
|
useGlobalIdForKeyName: true
|
|
|
}, cb);
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Load custom API responses.
|
|
|
*
|
|
|
* @param {Object} options
|
|
|
* @param {Function} cb
|
|
|
*/
|
|
|
loadResponses: function (cb) {
|
|
|
buildDictionary.optional({
|
|
|
dirname: sails.config.paths.responses,
|
|
|
filter: /(.+)\.(js|coffee|litcoffee)$/,
|
|
|
useGlobalIdForKeyName: true
|
|
|
}, cb);
|
|
|
},
|
|
|
|
|
|
optional: buildDictionary.optional,
|
|
|
required: buildDictionary.required,
|
|
|
aggregate: buildDictionary.aggregate,
|
|
|
|