Skip to content

Commit

Permalink
Add middleware to print access log
Browse files Browse the repository at this point in the history
  • Loading branch information
dominickp committed Feb 11, 2024
1 parent e9c730d commit cef3f2a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions javascript/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ const cli = require("./cli");
const app = express();
const port = 80;

/**
* Middleware to print access log
*/
app.use((req, res, next) => {
console.log(
`${req.ip} - - [${new Date().toUTCString()}] "${req.method} ${
req.originalUrl
} HTTP/${req.httpVersion}" ${res.statusCode}`
);
next();
});

/**
* Middleware to handle CORS.
*/
Expand Down

0 comments on commit cef3f2a

Please sign in to comment.