From f876e55c5cc8e7be25060581ef55b5dff9f631c6 Mon Sep 17 00:00:00 2001 From: Quinn Shanahan <3764+quinn@users.noreply.github.com> Date: Wed, 19 Apr 2023 10:59:03 -0400 Subject: [PATCH 1/2] Update README.md with middleware example fixes #285 --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index fa5b38d..f3c6f6f 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,23 @@ $ node example.js | pino-pretty #### Examples +##### Use as middleware +```js +const express = require('express') +const logger = require('pino-http') + +const app = express() + +app.use(logger()) + +function handle (req, res) { + req.log.info('something else') + res.end('hello world') +} + +app.listen(3000) +``` + ##### Logger options ```js From b943debcf340b4d9bb24e5789bfc0ae611a9b2f3 Mon Sep 17 00:00:00 2001 From: Quinn Shanahan <3764+quinn@users.noreply.github.com> Date: Wed, 26 Apr 2023 15:33:21 -0400 Subject: [PATCH 2/2] Update README.md Co-authored-by: James Sumners --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f3c6f6f..7fd9fd0 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ $ node example.js | pino-pretty #### Examples -##### Use as middleware +##### Use as Express middleware ```js const express = require('express') const logger = require('pino-http')