Abyss Monitor
  • Abyss Monitor
  • Setup
    • Core
    • Logger
    • Stats Performance
    • Store
    • Middleware
    • Alerts
  • Tutorials
    • Create an API
    • Distributed Cron Task
  • About
    • Links
Powered by GitBook
On this page
  • ContextMiddleware
  • LoggerSetupMiddleware
  • LoggerEndpointMiddleware
  1. Setup

Middleware

The Core Package provide multiple tools to help you to setup an easy to use logger. One on these are Express Middlewares.

ContextMiddleware

This middleware help you to generate and get an unique request ID (UUID).

// Add the middleware to your Express application
app.use(contextMiddleware);

// You can now get the current requestId from everywhere
getRequestContext()?.requestId // string | undefined

LoggerSetupMiddleware

This middleware you find the Controller name based on file naming *.controller.ts

It will also save the responseBody sent to the client.

// Add the middleware to your Express application
app.use(loggerEndpointMiddleware);

This middleware is a dependents middleware for loggerEndpointMiddleware

LoggerEndpointMiddleware

This middleware will log every request received from your API to the Monitor Dashboard

// Add the middleware to your Express application
app.use(loggerEndpointMiddleware);

// You can dynamically disable logging for specific request by adding
res.locals = {
  shouldNotPublishLog?: boolean; // To not publish the log and not log it to the console
  shouldNotSaveRequestBody?: boolean; // To not save the requestBody
  shouldNotSaveResponseBody?: boolean; // To not save the responseBody
}

You should enable shouldNotPublishLog for uptime endpoint to not pollute your dashboard

PreviousStoreNextAlerts

Last updated 8 months ago