Sotaro KARASAWA 10 лет назад
Родитель
Сommit
e8323de527
2 измененных файлов с 6 добавлено и 7 удалено
  1. 4 7
      lib/crowi/index.js
  2. 2 0
      test/utils.js

+ 4 - 7
lib/crowi/index.js

@@ -32,7 +32,6 @@ function Crowi (rootdir, env)
   this.config = {};
   this.mailer = {};
 
-  this.events = {};
 
   this.models = {};
 
@@ -40,6 +39,10 @@ function Crowi (rootdir, env)
   this.node_env = this.env.NODE_ENV || 'development';
   this.port = this.env.PORT || 3000;
 
+  this.events = {
+    user: new (require(self.eventsDir + 'user'))(this),
+  };
+
   if (this.node_env == 'development') {
     Promise.longStackTraces();
   }
@@ -54,12 +57,6 @@ Crowi.prototype.init = function() {
   .then(function() {
     // setup database server and load all modesl
     return self.setupDatabase();
-  }).then(function() {
-    // load events
-    self.events = {
-      user: new (require(self.eventsDir + 'user'))(self),
-    };
-    return Promise.resolve();
   }).then(function() {
     return self.setupModels();
   }).then(function() {

+ 2 - 0
test/utils.js

@@ -47,6 +47,8 @@ models.Page   = require(MODEL_DIR + '/page.js')(crowi);
 models.User   = require(MODEL_DIR + '/user.js')(crowi);
 models.Config = require(MODEL_DIR + '/config.js')(crowi);
 
+crowi.models = models;
+
 module.exports = {
   models: models,
   mongoose: mongoose,