diff --git a/index.js b/index.js index 8efe4592..cfdd1c65 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,12 @@ var path = require('path'); exports.Schema = require('./lib/schema').Schema; exports.AbstractClass = require('./lib/abstract-class').AbstractClass; exports.Validatable = require('./lib/validatable').Validatable; -exports.BaseSQL = require('./lib/sql'); + +var baseSQL = './lib/sql'; + +exports.__defineGetter__('BaseSQL', function () { + return require(baseSQL); +}); exports.init = function (rw) { if (global.railway) { @@ -12,7 +17,8 @@ exports.init = function (rw) { } else { rw.orm = {Schema: exports.Schema, AbstractClass: exports.AbstractClass}; } - require('./lib/railway')(rw); + var railway = './lib/railway'; + require(railway)(rw); }; try { @@ -23,5 +29,7 @@ try { } } catch (e) {} -exports.test = require('./test/common_test'); - +var commonTest = './test/common_test'; +exports.__defineGetter__('test', function () { + return require(commonTest); +}); diff --git a/lib/railway.js b/lib/railway.js index d8a54abe..46b45467 100644 --- a/lib/railway.js +++ b/lib/railway.js @@ -11,7 +11,7 @@ if (global.railway) { module.exports = function init(root) { var railway, app, models; - if (typeof root !== 'object' || root.constructor.name !== 'Compound') { + if (typeof root !== 'object' || (root.constructor.name !== 'Compound' && root.constructor.name !== 'CompoundServer')) { railway = global.railway; app = global.app; models = app.models;