1.0.1 • Published 1 year ago

express-auditor-mongodb v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

express-auditor-mongodb

An auditor for express requests-responses and store them in mongodb

Installation

Install this package in your NodeJS project

$ npm i express-auditor-mongodb

Getting started

Just import middleware and use it like this

import { Auditor } from "express-auditor-mongodb";

// make sure to use this route before your route handlers.
app.use(Auditor("Your mongoClient object"));

Example

Importing a auditor instance

import express from "express";
import { Auditor } from "express-auditor-mongodb";

const app = express();

// setup the body/response types to auditor catch him
app.use(express.json());

// the handler object return is the express middleware
app.use(handler);

// Place your auditor before your route handler.
app.use(Auditor("Your mongoClient object"));

// This will be the default schema used to store audit data ->
// statusCode, urlPath, body, query, responseBody, userAgent, ipAddress, createdAt

/*
  routes, middlewares, ...etc
*/

app.listen(3000, () => console.log("app is running"));
1.0.1

1 year ago

1.0.0

1 year ago