NotifyBC
Home
Docs
Help
GitHub
Home
Docs
Help
GitHub
  • Getting Started

    • Welcome
    • Overview
    • Quick Start
    • Installation
    • Web Console
    • What's New
  • Configuration

    • Configuration Overview
    • Database
    • Admin IP List
    • Reverse Proxy IP Lists
    • HTTP Host
    • Internal HTTP Host
    • Email
    • SMS
    • Subscription
    • Notification
    • Node Roles
    • Cron Jobs
    • RSA Keys
    • Worker Process Count
    • Middleware
    • OIDC
    • TLS Certificates
    • Queue
    • Logging
  • API

    • API Overview
    • Subscription
    • Notification
    • Configuration
    • Administrator
    • Bounce
  • Miscellaneous

    • Health Check
    • Disaster Recovery
    • Memory Dump
    • Benchmarks
    • Bulk Import
    • Developer Notes
    • Upgrade Guide
  • Meta

    • Code of Conduct
    • Security Reporting
    • Acknowledgments

Middleware

NotifyBC pre-installed following Express middleware as defined in src/middleware.ts

  • compression
  • helmet
  • morgan (disabled by default)

src/middleware.ts contains following default middleware settings

import path from 'path';
module.exports = {
  all: {
    compression: {},
  },
  apiOnly: {
    helmet: {},
    morgan: {
      params: [
        ':remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status ":req[X-Forwarded-For]"',
      ],
      enabled: false,
    },
  },
};

src/middleware.ts has following structure

module.exports = {
  all: {
    '<middlewareName>': {params: [], enabled: <boolean>},
  },
  apiOnly: {
    '<middlewareName>': {params: [], enabled: <boolean>},
  },
};

Middleware defined under all applies to both API and web console requests, as opposed to apiOnly, which applies to API requests only. params are passed to middleware function as arguments. enabled toggles the middleware on or off.

To change default settings defined in src/middleware.ts, create file src/middleware.local.ts or src/middleware.<env>.ts to override. For example, to enable access log,

module.exports = {
  apiOnly: {
    morgan: {
      enabled: true,
    },
  },
};
Prev
Worker Process Count
Next
OIDC