@@ -14,9 +14,9 @@ import { RegistryProxy } from "~/v3/registryProxy.server";
1414
1515const  app  =  express ( ) ; 
1616
17- //  if (process.env.DISABLE_COMPRESSION !== "1") {
18- //    app.use(compression());
19- //  }
17+ if  ( process . env . DISABLE_COMPRESSION  !==  "1" )  { 
18+   app . use ( compression ( ) ) ; 
19+ } 
2020
2121// http://expressjs.com/en/advanced/best-practice-security.html#at-a-minimum-disable-x-powered-by-header 
2222app . disable ( "x-powered-by" ) ; 
@@ -73,63 +73,15 @@ if (process.env.HTTP_SERVER_DISABLED !== "true") {
7373    next ( ) ; 
7474  } ) ; 
7575
76-   app . post ( "/realtime/v1/streams/express/test" ,  async  ( req ,  res )  =>  { 
77-     // Ensure the request is a readable stream 
78-     const  {  method,  headers }  =  req ; 
79-     console . log ( "Inside /realtime/v1/streams/express/test" ) ; 
80- 
81-     if  ( method  !==  "POST" )  { 
82-       return  res . status ( 405 ) . send ( "Method Not Allowed" ) ; 
83-     } 
76+   app . use ( ( req ,  res ,  next )  =>  { 
77+     // Generate a unique request ID for each request 
78+     const  requestId  =  nanoid ( ) ; 
8479
85-     // Set encoding to UTF-8 to read string data 
86-     req . setEncoding ( "utf8" ) ; 
87- 
88-     let  buffer  =  "" ; 
89- 
90-     try  { 
91-       req . on ( "data" ,  ( chunk )  =>  { 
92-         buffer  +=  chunk ; 
93-         const  lines  =  buffer . split ( "\n" ) ; 
94-         buffer  =  lines . pop ( )  ||  "" ; 
95- 
96-         for  ( const  line  of  lines )  { 
97-           if  ( line . trim ( ) )  { 
98-             const  data  =  JSON . parse ( line ) ; 
99-             console . log ( `${ new  Date ( ) . toISOString ( ) }   Received data:` ,  data ) ; 
100-             // You can process each data chunk as needed 
101-           } 
102-         } 
103-       } ) ; 
104- 
105-       req . on ( "end" ,  ( )  =>  { 
106-         if  ( buffer )  { 
107-           const  data  =  JSON . parse ( buffer ) ; 
108-           console . log ( `${ new  Date ( ) . toISOString ( ) }   Received data at end:` ,  data ) ; 
109-           // You can process the remaining data as needed 
110-         } 
111-         res . status ( 200 ) . send ( ) ;  // Send a success response 
112-       } ) ; 
113- 
114-       req . on ( "error" ,  ( error )  =>  { 
115-         console . error ( "Error processing stream:" ,  error ) ; 
116-         res . status ( 500 ) . send ( "Internal Server Error" ) ; 
117-       } ) ; 
118-     }  catch  ( error )  { 
119-       console . error ( "Error processing stream:" ,  error ) ; 
120-       res . status ( 500 ) . send ( "Internal Server Error" ) ; 
121-     } 
80+     runWithHttpContext ( {  requestId,  path : req . url ,  host : req . hostname ,  method : req . method  } ,  next ) ; 
12281  } ) ; 
12382
124-   // app.use((req, res, next) => { 
125-   //   // Generate a unique request ID for each request 
126-   //   const requestId = nanoid(); 
127- 
128-   //   runWithHttpContext({ requestId, path: req.url, host: req.hostname, method: req.method }, next); 
129-   // }); 
130- 
13183  if  ( process . env . DASHBOARD_AND_API_DISABLED  !==  "true" )  { 
132-     //  app.use(apiRateLimiter);
84+     app . use ( apiRateLimiter ) ; 
13385
13486    app . all ( 
13587      "*" , 
0 commit comments