33const express = require ( 'express' ) ;
44const basicAuth = require ( './basic-auth' ) ;
55
6+ function noop ( ) { }
7+
68class ExpressHTTPServer {
79 constructor ( options ) {
810 options = options || { } ;
@@ -13,8 +15,8 @@ class ExpressHTTPServer {
1315 this . password = options . password ;
1416 this . cache = options . cache ;
1517 this . gzip = options . gzip || false ;
16- this . preFastbootMiddlewares = options . preFastbootMiddlewares || [ ] ;
17- this . postFastbootMiddlewares = options . postFastbootMiddlewares || [ ] ;
18+ this . beforeMiddleware = options . beforeMiddleware || noop ;
19+ this . afterMiddleware = options . afterMiddleware || noop ;
1820
1921 this . app = express ( ) ;
2022 }
@@ -24,7 +26,7 @@ class ExpressHTTPServer {
2426 let username = this . username ;
2527 let password = this . password ;
2628
27- this . preFastbootMiddlewares . forEach ( args => app . use ( ... args ) ) ;
29+ this . beforeMiddleware ( app ) ;
2830
2931 if ( this . gzip ) {
3032 this . app . use ( require ( 'compression' ) ( ) ) ;
@@ -49,7 +51,7 @@ class ExpressHTTPServer {
4951
5052 app . get ( '/*' , fastbootMiddleware ) ;
5153
52- this . postFastbootMiddlewares . forEach ( args => app . use ( ... args ) ) ;
54+ this . afterMiddleware ( app ) ;
5355
5456 return new Promise ( resolve => {
5557 let listener = app . listen ( process . env . PORT || 3000 , ( ) => {
0 commit comments