@@ -7,9 +7,6 @@ var debug = require('debug')('crowi:crowi')
7
7
, sep = path . sep
8
8
, Promise = require ( 'bluebird' )
9
9
10
- , http = require ( 'http' )
11
- , express = require ( 'express' )
12
-
13
10
, mongoose = require ( 'mongoose' )
14
11
15
12
, models = require ( '../models' )
@@ -21,12 +18,13 @@ function Crowi (rootdir, env)
21
18
22
19
this . version = pkg . version ;
23
20
24
- this . rootDir = rootdir ;
25
- this . pluginDir = path . join ( this . rootDir , 'node_modules' ) + sep ;
26
- this . publicDir = path . join ( this . rootDir , 'public' ) + sep ;
27
- this . libDir = path . join ( this . rootDir , 'lib' ) + sep ;
28
- this . viewsDir = path . join ( this . libDir , 'views' ) + sep ;
29
- this . mailDir = path . join ( this . viewsDir , 'mail' ) + sep ;
21
+ this . rootDir = rootdir ;
22
+ this . pluginDir = path . join ( this . rootDir , 'node_modules' ) + sep ;
23
+ this . publicDir = path . join ( this . rootDir , 'public' ) + sep ;
24
+ this . libDir = path . join ( this . rootDir , 'lib' ) + sep ;
25
+ this . resourceDir = path . join ( this . rootDir , 'resource' ) + sep ;
26
+ this . viewsDir = path . join ( this . libDir , 'views' ) + sep ;
27
+ this . mailDir = path . join ( this . viewsDir , 'mail' ) + sep ;
30
28
31
29
this . config = { } ;
32
30
this . mailer = { } ;
@@ -71,8 +69,6 @@ Crowi.prototype.init = function() {
71
69
} ) ;
72
70
} ) . then ( function ( ) {
73
71
return self . setupMailer ( ) ;
74
- } ) . then ( function ( ) {
75
- return self . buildServer ( ) ;
76
72
} ) ;
77
73
}
78
74
@@ -182,25 +178,30 @@ Crowi.prototype.setupMailer = function() {
182
178
} ;
183
179
184
180
185
- Crowi . prototype . start = function ( app ) {
181
+ Crowi . prototype . start = function ( ) {
186
182
var self = this
183
+ , http = require ( 'http' )
187
184
, server
188
185
, io ;
189
186
190
- server = http . createServer ( app ) . listen ( self . port , function ( ) {
191
- console . log ( '[' + self . node_env + '] Express server listening on port ' + self . port ) ;
192
- } ) ;
187
+ return self . buildServer ( )
188
+ . then ( function ( app ) {
189
+ server = http . createServer ( app ) . listen ( self . port , function ( ) {
190
+ console . log ( '[' + self . node_env + '] Express server listening on port ' + self . port ) ;
191
+ } ) ;
193
192
194
- io = require ( 'socket.io' ) ( server ) ;
195
- io . sockets . on ( 'connection' , function ( socket ) {
196
- } ) ;
197
- this . io = io ;
193
+ io = require ( 'socket.io' ) ( server ) ;
194
+ io . sockets . on ( 'connection' , function ( socket ) {
195
+ } ) ;
196
+ self . io = io ;
197
+
198
+ return app ;
199
+ } ) ;
198
200
} ;
199
201
200
202
Crowi . prototype . buildServer = function ( ) {
201
- var app = express ( )
202
- , env = this . node_env
203
- , sessionConfig = this . setupSessionConfig ( ) ;
203
+ var express = require ( 'express' )
204
+ , app = express ( )
204
205
;
205
206
206
207
require ( './express-init' ) ( this , app ) ;
0 commit comments