pattern-singleton
CommunityGuarantee single shared instances instantly.
Authorjohnnystefan
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Prevents multiple instantiations of heavy shared resources such as database connections, caches, or configuration registries so the application avoids wasted memory and conflicting state. It also exposes a clear global access point so every consumer reuses the same lifecycle-managed object.
Core Features & Use Cases
- Lazy Initialization: A static getter handles the first creation and then reuses the stored instance whenever the service is needed.
- Private Constructor Enforcement: The class prevents direct constructor calls so the instance can only be created internally.
- Use Case: Wrap your NestJS PrismaService or Logger inside this pattern to ensure a single pipeline for database calls or logging across the backend.
Quick Start
Apply the singleton pattern to wrap your PrismaService so only one provider handles database connections across the NestJS application.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: pattern-singleton Download link: https://github.com/johnnystefan/test-saas-business/archive/main.zip#pattern-singleton Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.