pattern-proxy

Implement proxy objects for NestJS services with guards, caching, and lazy loading.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/johnnystefan/test-saas-business --skill pattern-proxy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pattern-proxy
Source: https://github.com/johnnystefan/test-saas-business/tree/main/skills/design-patterns/structurals/pattern-proxy
Command: npx skills add https://github.com/johnnystefan/test-saas-business --skill pattern-proxy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill guides architects to create proxies that control access to services, add cross-cutting behaviors like logging or caching, and delay instantiation until the real object is needed.

Core Features & Use Cases

  • Shared Interface Enforcement: Define a common interface so callers remain unaware that requests may go through a proxy.
  • Access Control & Lazy Initialization: Use the proxy to enforce guards, lazily instantiate heavy aggregates, and log every request before delegating.
  • Use Case: Wrap a repository with a proxy that enforces tenant isolation, caches responses, and logs access without touching the core data service.

Quick Start

Wrap the member domain service in a proxy that guards access, lazily instantiates the real service, and logs each request before delegating.

Frequently Asked Questions about pattern-proxy

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

FAQPage Schema
How do I add logging and caching to a NestJS service without modifying its core code?

You can wrap your NestJS service in a proxy object that matches its shared interface, intercepting calls to add logging and caching without modifying the core service code.

What is the proxy design pattern used for in software engineering?

The proxy design pattern controls access to a core service by acting as a placeholder wrapper. It manages access, enforces checks, and adds behaviors like lazy loading or caching before delegating calls to the real subject.

How do I implement lazy loading for resource-heavy services in NestJS?

You can wrap your resource-heavy service in a proxy that delays instantiation until the real object is actually needed. The proxy enforces a shared interface and lazily initializes the subject upon the first method call.

Can I enforce tenant isolation and access control using a proxy in NestJS?

Yes, you can wrap a repository with a proxy to enforce tenant isolation and access control. The proxy intercepts requests, runs access checks or guards, and logs access before delegating to the core data service.

When should I use a proxy pattern instead of directly calling a service?

Use a proxy pattern when you need to control access, enforce tenant isolation, cache responses, or delay instantiation of heavy aggregates. It is ideal when you want to keep cross-cutting behaviors separate from core service logic.