@meeshkanml/express-middleware
v0.0.6
Published
Express middleware to create .jsonl files for consumption by Meeshkan.
Readme
Meeshkan express middleware
Express server middleware to log requests and responses in the HTTP Types format.
Installation
Install via npm:
npm install @meeshkanml/express-middlewareUsage
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 routesDevelopment
Install dependencies:
$ yarnRun tests:
$ yarn testCompile TypeScript:
$ yarn compilePublish package:
$ yarn publish --access publicPush git tags:
$ TAG=v`cat package.json | grep version | awk 'BEGIN { FS = "\"" } { print $4 }'`
$ git tag -a $TAG -m $TAG
$ git push origin $TAG