jsout-express
TypeScript icon, indicating that this package has built-in type declarations

1.1.7 • Public • Published

jsout-express

build status semantic-release Conventional Commits SemVer

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

Package Sidebar

Install

npm i jsout-express

Weekly Downloads

23

Version

1.1.7

License

MIT

Unpacked Size

12.5 kB

Total Files

8

Last publish

Collaborators

  • mhweiner