interface MultiTenancyPluginOptions

Top-level options for MultiTenancyPlugin.

Properties

Which resolver(s) to use for tenant resolution (required).

Options forwarded to HeaderResolver.

Options forwarded to PathResolver.

Options forwarded to JwtResolver.

Security note: the resolver reads the tenant id from an UNVERIFIED JWT claim — a client can mint a token naming any tenant. Acceptable only alongside authentication middleware which separately verifies the token. A register() warning fires when the resolved chain contains a JwtResolver.

Database-isolation strategy: a discriminant string, or a custom ITenantIsolationStrategy instance. Default: 'column-per-tenant'.

A strategy NAMES the isolation an ITenantDataStore is expected to implement; it does not by itself create schemas or databases. The shipped MemoryTenantDataStore uses the strategy's label as a partition-map key, so all three kinds isolate correctly on it — but no shipped adapter is told the strategy. A register() warning fires when a non-'column-per-tenant' strategy is selected with no dataStore.

An application-provided data store. When absent the plugin ships a zero-dependency MemoryTenantDataStore.

Cache-prefix behaviour.

optional
required: boolean

When true and no resolver returns a tenant, short-circuit with an error response. Default: false.

optional
rejectionStatus: number

HTTP status code returned when short-circuiting (default 400).

optional
middlewarePriority: number

Priority passed to ctx.middleware.add (default 40).

optional
exclude: readonly PathPattern[]

Paths that skip tenant resolution entirely — no resolver runs, no tenant is stamped, and a required deployment does not reject them. Matched against ctx.request.path by exact string equality or RegExp.test.

Default when omitted: the operational probes the framework's own plugins serve — ['/live', '/ready', '/health', '/metrics', '/openapi.json', '/docs']. A matching path goes straight to next(). Pass [] to restore the previous behaviour (no path is exempt) for an application whose own routes sit on those paths.

Usage

import { type MultiTenancyPluginOptions } from "multi-tenancy-plugin/src/index.ts";