← Back to design patterns mapstructural
🎁
Design Pattern
Decorator
Wrap an object to add behavior without changing the original class.
Visual Diagram
Base service -> Auth wrapper -> Log wrapper -> Cache wrapper
When To Use
- ->Adding logging, caching, or auth around services
- ->Express-style middleware layers
- ->Extending behavior without subclass explosion
Used in: Express middleware, NestJS decorators, service wrappers
decorator.js
Live Editor
Loading...
Output
Run code to see output...