@meeshkanml/express-middleware
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

CircleCI npm version

Meeshkan express middleware

Express server middleware to log requests and responses in the HTTP Types format.

Installation

Install via npm:

npm install @meeshkanml/express-middleware

Usage

Add this middleware before adding routes, otherwise it won't work.

const mw, { LocalFileSystemTransport } = require("@meeshkan/express-middleware");

// Add custom transports with signature
// `type HttpExchangeTransport = (httpExchange: HttpExchange) => Promise<void>;`
// Here `HttpExchange` is defined in `ts-http-types`
const customTransport = async httpExchange => {
  console.log("Got http exchange", httpExchange);
};

// Add middleware
app.use(
  middleware({
    transports: [
      LocalFileSystemTransport("http-exchanges.jsonl"),
      customTransport
    ],
  })
);
// add routes

Development

Install dependencies:

$ yarn

Run tests:

$ yarn test

Compile TypeScript:

$ yarn compile

Publish package:

$ yarn publish --access public

Push git tags:

$ TAG=v`cat package.json | grep version | awk 'BEGIN { FS = "\"" } { print $4 }'`
$ git tag -a $TAG -m $TAG
$ git push origin $TAG

/@meeshkanml/express-middleware/

    Package Sidebar

    Install

    npm i @meeshkanml/express-middleware

    Weekly Downloads

    0

    Version

    0.0.6

    License

    MIT

    Unpacked Size

    18.8 kB

    Total Files

    13

    Last publish

    Collaborators

    • carolstran
    • k4m4
    • kimmo-meeshkan
    • meeshkan