service-pattern-nestjs

Create Model and Orchestration services for NestJS with repository-based data access.

1|Updated Jan 2, 2025
One-click install
npx skills add https://github.com/allenlin90/eridu-services --skill service-pattern-nestjs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: service-pattern-nestjs
Source: https://github.com/allenlin90/eridu-services/tree/main/.agent/skills/service-pattern-nestjs
Command: npx skills add https://github.com/allenlin90/eridu-services --skill service-pattern-nestjs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Comprehensive pattern guidelines and boilerplate for implementing NestJS services at scale, including Model Services, Orchestration Services, and business logic with NestJS decorators, to promote consistency and maintainability across modules.

Core Features & Use Cases

  • Standardized service layering using BaseModelService, Model/Orchestration separation, and repository-driven data access.
  • Support for transactional orchestration with CLS-based @Transactional, and safe error handling patterns.
  • Enforced validation via schema payloads and decoupling from ORM types within service methods.

Quick Start

Create a new NestJS service by extending BaseModelService, inject the repository, and follow the Model and Orchestration patterns described in this skill to implement consistent business logic.

Frequently Asked Questions about service-pattern-nestjs

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

FAQPage Schema
How do I structure NestJS services for multi-entity workflows?

To structure NestJS services for multi-entity workflows, use an Orchestration Service pattern to coordinate across modules while relying on Model Services for single-entity operations. This separation enforces clear layering and decouples business logic from data access.

What is the best way to decouple NestJS services from the ORM?

The best way to decouple NestJS services from the ORM is by applying a repository pattern for data access. This approach uses repository-driven methods within the service layer to prevent direct ORM type dependencies in business logic.

How do I handle transactions in NestJS orchestration services?

Handle transactions in NestJS orchestration services by applying CLS-based @Transactional decorators. This pattern supports explicit orchestration transactions for multi-entity workflows, ensuring consistent data operations across module boundaries.

How do I standardize error handling and data reads in NestJS?

Standardize error handling and data reads in NestJS by using domain or HTTP-safe error patterns for failures and implementing safe read paths that return null. This approach prevents unhandled exceptions and standardizes missing data responses.

When should I separate Model Services and Orchestration Services in NestJS?

Separate Model Services and Orchestration Services in NestJS when scaling applications to maintain consistency across modules. Use Model Services for isolated single-entity operations and Orchestration Services when coordinating complex multi-entity business logic.

Do I need schema payloads to validate inputs in NestJS services?

Yes, you need schema payloads to validate inputs in NestJS services. Enforcing validation via schema payloads ensures that business logic receives properly structured data before executing repository-driven data access operations.