Simple express request logger middleware for jsout.
{
"level": 30,
"message": "req",
"data": {
"method": "GET",
"url": "/",
"hostname": "localhost",
"ip": "::ffff:127.0.0.1",
"statusCode": 200,
"statusMessage": "OK",
"durationMs": 3.2342
},
"context": {
"date": "2022-12-20T04:52:03.622Z",
"pid": 10728,
"ppid": 10725,
"nodeVersion": "v16.13.0"
}
}
npm i jsout jsout-express
Include it like you would any other middleware, but it should be first (or towards the top) to be accurate. At the very least, it must be before any other handler that might send a response.
import {express} from 'express';
import {logger} from 'jsout';
import {logRequest} from 'jsout-express';
const app = express();
// should be first, before other middlewares
app.use(logRequest);
// ... other things ...
app.listen();
Please contribute to this project! Issue a PR against master
and request review.
- Please test your work thoroughly.
- Make sure all tests pass with appropriate coverage.
npm i
npm test