@@ -18,9 +18,9 @@ app.use((req, res, next) => {
1818} ) ;
1919
2020app . get ( '/' , ( req , res ) => {
21+ const userAgent = new UserAgents ( ) . toString ( ) ;
2122 res . status ( 200 ) . json ( { message : 'Hello Express!' } ) ; // Respond with JSON
22- console . log ( `Received GET request to the API with userAgent:` ) ;
23- console . log ( userAgent . toString ( ) ) ;
23+ console . log ( `Received GET request to the API with userAgent: ${ userAgent } ` ) ;
2424} ) ;
2525
2626app . post ( '/' , ( req , res ) => {
@@ -30,23 +30,23 @@ app.post('/', (req, res) => {
3030
3131app . put ( '/user' , ( req , res ) => {
3232 try {
33+ const userAgent = new UserAgents ( ) . toString ( ) ;
3334 // Ensure the request body is parsed and simulate an error if requested
3435 if ( req . body && req . body . simulateError ) {
3536 throw new Error ( 'Simulated server error' ) ;
3637 }
3738 res . status ( 200 ) . json ( { message : 'Resource updated successfully' } ) ;
38- console . log ( `Received PUT request from port: ${ port } to ${ dir } userAgent:` ) ;
39- console . log ( userAgent . toString ( ) ) ;
39+ console . log ( `Received PUT request from port: ${ port } to ${ dir } userAgent: ${ userAgent } ` ) ;
4040 } catch ( error ) {
4141 res . status ( 500 ) . json ( { error : 'Internal server error' } ) ; // Handle server error
4242 console . error ( 'Error occurred on PUT /user:' , error . message ) ;
4343 }
4444} ) ;
4545
4646app . delete ( '/user' , ( req , res ) => {
47+ const userAgent = new UserAgents ( ) . toString ( ) ;
4748 res . status ( 204 ) . send ( ) ; // Respond with 204 for successful deletion
48- console . log ( `Received DELETE request from port: ${ port } to ${ dir } userAgent:` ) ;
49- console . log ( userAgent . toString ( ) ) ;
49+ console . log ( `Received DELETE request from port: ${ port } to ${ dir } userAgent: ${ userAgent } ` ) ;
5050} ) ;
5151
5252// POST /user route
0 commit comments