New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

meercat

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meercat

A simple yet effective request logger middleware for Nest JS

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

MeerCat - NestJS Request Logging Middleware

Meercat

The name comes from the animal, Meerkat, which is always extremely focused on its environment in order to protect its colony, and CAT, the UNIX utility which outputs text.

This is a NestJS middleware that serves a simple yet missing functionality in NestJS : logging HTTP requests and errors, like Morgan with Express. It offers several features like customization and detailed error logging

Install and Usage

npm i meercat

Then, in your main app.module.ts

import { MeercatLoggingMiddleware } from 'meercat';

// Declare the middleware on all routes
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(MeercatLoggingMiddleware).forRoutes('*');
  }
}

Options

Custom Logger

By default, Meercat uses the default NestJS logger, only handling the timestamp a bit differently. You can override this behaviour by providing the token MEERCAT_LOGGER with the desired logger.

MeercatOptions

You can customize the logger behaviour by providing the token MEERCAT_OPTIONS with a MeercatOptions object :

export type MeercatOptions = {
  name?: string;
  logErrorDetails?: boolean; // default true
  blacklisted?: string[]
};

name : Customize the logger name logErrorDetails : logs the query, body and user agent to the console when the request status >= 400. log level: debug blacklisted : a list of keywords, if the keyword is included in the req.baseUrl, the request won't be logged (can be used to prevent clutter)

Example :

  providers: [
    {
      provide: MEERCAT_OPTIONS,
      useValue: { logErrorDetails: false } as MeercatOptions,
    },
  ],

Keywords

NestJS

FAQs

Package last updated on 25 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts