From 9355d948761b21167e010fe0bf1bd017e975ca05 Mon Sep 17 00:00:00 2001 From: Samuel Reed Date: Tue, 27 May 2014 18:07:44 +0800 Subject: [PATCH] Require data-sources directory in addition to models directory. This prevents a potential issue where a model is loaded from config that specifies a datasource that is loaded via JS. The model would typically be loaded before the datasource in this case, leading to an error. This allows the files in `data-sources` to be loaded with the full `appConfig` attached to the app object. Signed-off-by: Samuel Reed --- lib/application.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index 3ceed3686..68bf8e137 100644 --- a/lib/application.js +++ b/lib/application.js @@ -471,11 +471,13 @@ app.boot = function(options) { forEachKeyedObject(dataSourceConfig, function(key, obj) { app.dataSource(key, obj); }); + requireDir(path.join(appRootDir, 'data-sources')); // instantiate models forEachKeyedObject(modelConfig, function(key, obj) { app.model(key, obj); }); + requireDir(path.join(appRootDir, 'models')); // try to attach models to dataSources by type try { @@ -497,7 +499,6 @@ app.boot = function(options) { } // require directories - var requiredModels = requireDir(path.join(appRootDir, 'models')); var requiredBootScripts = requireDir(path.join(appRootDir, 'boot')); }