nestjs-backend-patterns

Implements NestJS backend patterns for multitenancy, authentication, authorization, and third-party integrations.

Updated Jun 14, 2026
One-click install
npx skills add https://github.com/ironkid90-s/lucky5-v7 --skill nestjs-backend-patterns-ironkid90-s
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nestjs-backend-patterns
Source: https://github.com/ironkid90-s/lucky5-v7/tree/main/.ptah/skills/nestjs-backend-patterns
Command: npx skills add https://github.com/ironkid90-s/lucky5-v7 --skill nestjs-backend-patterns-ironkid90-s

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building a multi-tenant SaaS backend in NestJS requires consistent patterns for tenant isolation, authentication, authorization, and external service integration, and ad-hoc implementations lead to security gaps and unmaintainable code. ## Core Features & Use Cases - Provider Pattern for Third-Party Services: Standardized factory-based integration for payments, email, storage, and auth providers with swappable adapters. - Multitenancy with Prisma + ZenStack: Shared-schema tenant isolation enforced declaratively at the data layer using CLS-based request context. - JWT Authentication and RBAC Authorization: Complete Passport JWT strategy, guards, decorators, and role-permission mappings. - Use Case: When adding Stripe payments to a multi-tenant NestJS app, use this Skill to scaffold the provider factory, adapter, service, module, and webhook controller following the established pattern. ## Quick Start Use the nestjs-backend-patterns skill to implement a Stripe payment integration with the provider pattern in my NestJS project.

Frequently Asked Questions about nestjs-backend-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I integrate third-party APIs like Stripe into NestJS?

Use the provider pattern: define a client interface, create a factory provider that returns the configured adapter based on environment config, wrap it in an injectable service, and export it from a module. This lets you swap providers like Stripe, Paddle, or LemonSqueezy via configuration.

How to implement multitenancy in NestJS with Prisma?

Use a shared schema with tenant ID enforced by ZenStack access policies. Store the current user in CLS (Continuation Local Storage) via middleware, then return an enhanced Prisma client from a request-scoped service so all queries are automatically filtered by tenant.

What is the difference between ZenStack and plain Prisma for access control?

Prisma provides type-safe database access only, while ZenStack extends it with declarative @@allow policies defined in the schema. ZenStack's enhance() function wraps the Prisma client to enforce read, create, update, and delete rules at the data layer based on the authenticated user.

Does NestJS RBAC work with JWT authentication guards?

Yes, register JwtAuthGuard, RolesGuard, and PermissionsGuard globally via APP_GUARD in order. The JWT guard populates request.user, then role and permission guards read metadata from @Roles and @RequirePermissions decorators to allow or deny access.

When should I use database-per-tenant instead of shared schema multitenancy?

Use database-per-tenant for enterprise or compliance-heavy workloads needing the highest isolation, accepting higher cost and complexity. Shared schema with tenant ID suits most SaaS applications due to lower cost and simpler operations.