jsout-express
Simple express request logger middleware for jsout.
Log example
{
"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"
}
}
Installation
npm i jsout jsout-express
Usage
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();
Contribution
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.
How to build locally
npm i
Running tests
npm test