WayrApp Backend & Ecosystem Documentation - v1.0.0
    Preparing search index...

    Function performanceMiddleware

    • Express middleware factory for automatic HTTP request performance tracking.

      Creates middleware that automatically measures response times and tracks error rates for all HTTP requests. Integrates seamlessly with Express applications and requires no manual instrumentation. The middleware is non-blocking and adds minimal overhead to request processing.

      Parameters

      Returns (_req: any, res: any, next: any) => void

      Express middleware function for automatic request tracking

      // Basic usage with singleton monitor
      import { performanceMiddleware, performanceMonitor } from '@/shared/utils/performance';
      app.use(performanceMiddleware(performanceMonitor));
      // Usage with custom monitor instance
      const customMonitor = new PerformanceMonitor();
      app.use(performanceMiddleware(customMonitor));
      // Conditional usage (skip in test environment)
      if (process.env.NODE_ENV !== 'test') {
      app.use(performanceMiddleware(performanceMonitor));
      }