@@ -57,17 +57,20 @@ class Application extends Configurable {
5757 this . configureEnvironment ( )
5858
5959 /*
60- * Build container
60+ * Prepare container
6161 */
6262 const containerBuilder = new ContainerBuilder ( this )
6363 containerBuilder . configure ( { includeComponents : true } )
6464
6565 /*
66- * Create and daemonize databases
66+ * Start and daemonize databases
6767 */
6868 this . databasesManager = new DatabasesManager ( this , containerBuilder . container )
6969 this . databasesManager . load ( )
7070
71+ /*
72+ * Build container
73+ */
7174 containerBuilder . addToBuild ( 'component.databasesmanager' , this . databasesManager )
7275
7376 /*
@@ -110,7 +113,6 @@ class Application extends Configurable {
110113 this . plugAuthentication ( )
111114 this . router . load ( )
112115 this . initializePassport ( )
113- this . plugMiddlewareLogger ( )
114116 this . app . use ( '/' , this . router . scope )
115117 }
116118
@@ -159,6 +161,13 @@ class Application extends Configurable {
159161 */
160162 this . app . use ( bodyParser . json ( ) ) // support json encoded bodies
161163 this . app . use ( bodyParser . urlencoded ( { extended : true } ) ) // support encoded bodies
164+
165+ if ( this . config . app . log ) {
166+ this . app . use ( morgan (
167+ ':date - [:method :url] - [:status, :response-time ms, :res[content-length] B] - [HTTP/:http-version, :remote-addr, :user-agent]' ,
168+ { stream : fs . createWriteStream ( `${ this . kernel . path . root } /logs/traffic.log` , { flags : 'a' } ) }
169+ ) )
170+ }
162171 }
163172
164173 /**
@@ -176,9 +185,7 @@ class Application extends Configurable {
176185 }
177186
178187 req . setEncoding ( 'utf8' )
179- req . on ( 'data' , chunk => {
180- data += chunk
181- } )
188+ req . on ( 'data' , chunk => data += chunk )
182189 req . on ( 'end' , ( ) => {
183190 req . rawBody = data
184191 next ( )
@@ -210,15 +217,6 @@ class Application extends Configurable {
210217 this . app . use ( passport . initialize ( ) )
211218 }
212219
213- /**
214- * plugMiddlewareLogger - Trace everything that happens on the server
215- */
216- plugMiddlewareLogger ( ) {
217- if ( this . config . app . log ) {
218- this . app . use ( morgan ( ':date - [:method :url] - [:status, :response-time ms, :res[content-length] B] - [HTTP/:http-version, :remote-addr, :user-agent]' , { stream : fs . createWriteStream ( `${ this . kernel . path . root } /logs/traffic.log` , { flags : 'a' } ) } ) )
219- }
220- }
221-
222220 /**
223221 * getEnv - get node environment
224222 *
0 commit comments