Skip to main content

Class: GateWatcher

Defined in: watchers/gate.watcher.ts:26

GateWatcher tracks authorization checks in NestJS applications. Monitors gate/policy evaluations to track what resources users can access, capturing gate name, action, subject, allowed/denied status, and user information.

Implements​

  • OnModuleInit
  • OnModuleDestroy

Constructors​

Constructor​

new GateWatcher(collector, nestlensConfig, gateService?): GateWatcher

Defined in: watchers/gate.watcher.ts:31

Parameters​

collector​

CollectorService

nestlensConfig​

NestLensConfig

gateService?​

unknown

Returns​

GateWatcher

Methods​

onModuleDestroy()​

onModuleDestroy(): void

Defined in: watchers/gate.watcher.ts:98

Puts the authorization service back the way it was.

Without this the host goes on calling through a watcher whose collector is gone, and a process that builds the module more than once against the same service — as tests and nest start --hmr do — wraps each round on top of the last.

Returns​

void

Implementation of​

OnModuleDestroy.onModuleDestroy


onModuleInit()​

onModuleInit(): void

Defined in: watchers/gate.watcher.ts:43

Returns​

void

Implementation of​

OnModuleInit.onModuleInit


trackCheck()​

trackCheck(gate, action, subject, allowed, user?, reason?): void

Defined in: watchers/gate.watcher.ts:107

Manual tracking method for authorization checks. Call this manually from your authorization logic if auto-wrapping doesn't work.

Parameters​

gate​

string

action​

string

subject​

unknown

allowed​

boolean

user?​

unknown

reason?​

string

Returns​

void