UNPKG

@hz-9/a5-tenant

Version:

Tenant module for the @hz-9/a5-* series of repositories.

25 lines (24 loc) 823 B
import { CanActivate, ExecutionContext } from '@nestjs/common'; import type { A5TenantGuardConstructorOptions } from '../interfaces/tenant'; import type { A5TenantService } from './a5-tenant.service'; /** * 租户检查 Guard * * 从 headers 或 route params 中获取租户 ID,并检查租户是否存在 * * @public */ export declare class A5TenantGuard implements CanActivate { private readonly tenantService; private readonly options; constructor(options: A5TenantGuardConstructorOptions, tenantService: A5TenantService); canActivate(context: ExecutionContext): Promise<boolean>; private parseFromHeaders; /** * 从 headers 中获取租户 ID * * @param request - FastifyRequest 对象 * @returns 租户 ID 或 undefined */ private getTenantIdFromHeaders; }