nestjs-microservices
gRPC, RabbitMQ standards and Monorepo contracts.
Installation
Suivez les instructions du dépôt pour votre agent. Consultez les fichiers et dépendances avant l’installation.
Voir la source ↗GuidesInstructions
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
.protocontracts.
-
Why: 10x faster than REST/JSON, centralized
-
Asynchronous (Events): Use RabbitMQ or Kafka for decoupling domains.
-
Pattern: Fire-and-forget (
emit()) for side effects (e.g., "UserCreated" -> "SendEmail").
-
Pattern: Fire-and-forget (
Monorepo Architecture
-
Contracts:
-
Pattern: Store all DTOs,
.protofiles, and Interfaces in a Shared Library (libs/contracts). -
Rule: Services never import code from other services. They only import from
contracts.
-
Pattern: Store all DTOs,
- Versioning: Semantic versioning of messages is mandatory. Never change a field type; add a new field.
Exception Handling
-
Propagation: Standard
HttpExceptionis lost over Rpc/Tcp. -
Standard: Use
RpcExceptionand 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-validatorjust like HTTP.-
Config: Apply
useGlobalPipes(new ValidationPipe({ transform: true }))in theMicroserviceOptionssetup, not just HTTP app setup.
-
Config: Apply
Exemples
Consultez les exemples du dépôt source.
Voir la source ↗Historique source
- Date d’indexation
- 2026-01-20
- Mise à jour de l’index
- 2026-01-26
- Branch
- main
Les dates concernent ce répertoire. Consultez le dépôt pour l’historique du code.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!