UNPKG

@kitstack/nest-powertools

Version:

A comprehensive collection of NestJS powertools, decorators, and utilities to supercharge your backend development

52 lines 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GuardRegistryService = exports.DefaultRoles = void 0; var DefaultRoles; (function (DefaultRoles) { DefaultRoles["ADMIN"] = "admin"; DefaultRoles["USER"] = "user"; DefaultRoles["MODERATOR"] = "moderator"; DefaultRoles["GUEST"] = "guest"; DefaultRoles["SUPER_ADMIN"] = "super_admin"; DefaultRoles["EDITOR"] = "editor"; DefaultRoles["MANAGER"] = "manager"; })(DefaultRoles || (exports.DefaultRoles = DefaultRoles = {})); class GuardRegistryService { constructor() { this.guards = {}; } static getInstance() { if (!GuardRegistryService.instance) { GuardRegistryService.instance = new GuardRegistryService(); } return GuardRegistryService.instance; } registerGuard(name, guard) { this.guards[name] = guard; } getGuard(name) { const guard = this.guards[name]; if (!guard) { throw new Error(`Guard '${name}' not found in registry. Available guards: ${Object.keys(this.guards).join(', ')}`); } return guard; } getRegisteredGuards() { return Object.keys(this.guards); } hasGuard(name) { return name in this.guards; } unregisterGuard(name) { if (this.hasGuard(name)) { delete this.guards[name]; return true; } return false; } clearAll() { this.guards = {}; } } exports.GuardRegistryService = GuardRegistryService; //# sourceMappingURL=auth-interfaces.js.map