Skip to content

feat: add TenantLimitGuard to enforce user and storage limits on tena…#1074

Open
codenerde wants to merge 1 commit into
rinafcode:mainfrom
codenerde:test
Open

feat: add TenantLimitGuard to enforce user and storage limits on tena…#1074
codenerde wants to merge 1 commit into
rinafcode:mainfrom
codenerde:test

Conversation

@codenerde

Copy link
Copy Markdown

closes #843 Introduces \TenantLimitGuard\ that enforces \userLimit\ on user creation and \storageLimit\ on content upload, returning \402 Payment Required\ when limits are exceeded.

Changes
New \src/tenancy/guards/tenant-limit.guard.ts — Guard + @LimitType\ decorator. Checks \currentUserCount >= userLimit\ (user) or \currentStorageUsage + uploadMB > storageLimit\ (storage). Bypasses on -1\ (unlimited).
\src/auth/auth.controller.ts — Added \POST /auth/register\ with @LimitType('user')\ guard, duplicate email/username checks, and tenant user count tracking.
\src/cdn/cdn.controller.ts — Applied @LimitType('storage')\ guard to \POST /cdn/upload.
\src/tenancy/tenancy.module.ts — Registered and exported \TenantLimitGuard.
\src/cdn/cdn.module.ts, \src/auth/auth.module.ts — Imported \TenancyModule\ for guard resolution.
\src/tenancy/guards/tenant-limit.guard.spec.ts — 11 unit tests covering at-limit, over-limit, boundary, and unlimited scenarios.
Closes #843

@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@codenerde Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tenant resource limit enforcement in API request handlers

1 participant