askill
nestjs-microservices

nestjs-microservicesSafety 85Repository

gRPC, RabbitMQ standards and Monorepo contracts.

197 stars
3.9k downloads
Updated 2/2/2026

Package Files

Loading files...
SKILL.md

Microservices & Transport Standards

Priority: P0 (FOUNDATIONAL)

Microservices communication patterns and transport layer standards.

  • Synchronous (RPC): Use gRPC for low-latency, internal service-to-service calls.
    • Why: 10x faster than REST/JSON, centralized .proto contracts.
  • Asynchronous (Events): Use RabbitMQ or Kafka for decoupling domains.
    • Pattern: Fire-and-forget (emit()) for side effects (e.g., "UserCreated" -> "SendEmail").

Monorepo Architecture

  • Contracts:
    • Pattern: Store all DTOs, .proto files, and Interfaces in a Shared Library (libs/contracts).
    • Rule: Services never import code from other services. They only import from contracts.
  • Versioning: Semantic versioning of messages is mandatory. Never change a field type; add a new field.

Exception Handling

  • Propagation: Standard HttpException is lost over Rpc/Tcp.

  • Standard: Use RpcException and generic Filters.

    // Global RPC Filter
    @Catch()
    export class RpcExceptionFilter implements RpcExceptionFilter<RpcException> {
      catch(exception: RpcException, host: ArgumentsHost): Observable<any> {
        return throwError(() => exception.getError());
      }
    }
    

Serialization

  • Message DTOs: Use class-validator just like HTTP.
    • Config: Apply useGlobalPipes(new ValidationPipe({ transform: true })) in the MicroserviceOptions setup, not just HTTP app setup.

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

92/100Analyzed 2/6/2026

A high-quality, actionable guide for NestJS microservices. It provides clear architectural standards, code examples for error handling, and specific triggers for agent discovery.

85
95
90
90
95

Metadata

Licenseunknown
Version-
Updated2/2/2026
PublisherHoangNguyen0403

Tags

api