File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ const Hapi = require ( "hapi" ) ;
2
+
3
+ let port = 8000 ;
4
+
5
+ // Initialize a new server
6
+ let server = new Hapi . Server ( ) ;
7
+
8
+ server . connection ( { port : process . env . PORT || port } ) ;
9
+
10
+ // Report each response made
11
+ server . ext ( "onPreResponse" , ( req , rep ) => {
12
+ let res = req . response ;
13
+
14
+ console . log ( "Outcoming response:" ) ;
15
+ console . log ( `in: ${ new Date } ` ) ;
16
+ console . log ( `to: ${ req . info . remoteAddress } ` ) ;
17
+ console . log ( `method: ${ req . method } ` ) ;
18
+ console . log ( `url: ${ req . url . path } ` ) ;
19
+ console . log ( `status: ${ res . statusCode || res . output . statusCode } ` ) ;
20
+ console . log ( ) ;
21
+
22
+ rep . continue ( ) ;
23
+ } ) ;
24
+
25
+ // Print message once started
26
+ server . start ( ( err ) => {
27
+ if ( err ) throw err ;
28
+
29
+ console . log ( ) ;
30
+ console . log ( "---------- -------- ------ ---- --" ) ;
31
+ console . log ( "----- ---- --- -- -" ) ;
32
+ console . log ( `Server running at ${ port } ` ) ;
33
+ console . log ( "----- ---- --- -- -" ) ;
34
+ console . log ( "---------- -------- ------ ---- --" ) ;
35
+ console . log ( ) ;
36
+ } ) ;
You can’t perform that action at this time.
0 commit comments