@micro-nest/common
v1.0.17
Published
Microservices decorators and helpers for nest
Downloads
23
Readme
MICRO-NEST
Quick Start
Install
npm i @micro-nest/common
Imports
import { Listner, Listen, MicroConnect, Micro } from "@micro-nest/common"
import { Call } from "@micro-nest/common" # for gateway only
import { MicroException, ValidationException } from "@micro-nest/common"
Description
- Provides a set of decorators to help you build microservices with NestJs
- Provides a set of helper functions to help you build microservices with NestJs
- RPC exception filter to handle exceptions thrown by microservices
- Transport layers to connect microservices with NestJs
Code Less & Do More
- Naming conventions based decorators and function.
- Default is configured, just pass the options you want to override.
- Easy to use and configure.
Architecture
- Microservices architecture is used to build these decorators & helper functions, where default transport layer is RabbitMQ ,however you can configure your transport layer according to your need from available transport layers. Sub nest projects are used to create individual microservices, microservices from other langauge, framework is also supported.
Transport Layers:
TCP
tcp(host?:string, port?:number)
RABBITMQ
rabbitmq(queue?:string, url?:string)
REDIS
redis(host?:string, port?:number, password?:string, tls?: any)
KAFKA
kafka(broker?:string)
Decorators:
@MicroConnect()
- Used to connect to a microservice
export class UserService { @MicroConnect() auth: ClientProxy }
@Micro()
- Used to call a microservice event
export class UserService { @MicroConnect() auth: ClientProxy @Micro() create() {} }
@Listner()
- Used to register a listner class
@Listner() export class UserListner { }
@Listen()
- Used to listen a microservice event
@Listner() export class UserListner { @Listen() create() {} }
Default CRUD functions available
- create() {}
- findAll() {}
- findOne() {}
- findOrFail() {}
- update() {}
- updateAll() {}
- softDelete() {}
- hardDelete() {}
- paginate() {}
- ping() {}
- pong() {}
Exceptions:
- throw new MicroException()
- throw new ValidationException()
Strategy:
- retryStrategy
Todo:
- [ ] Add more transport layers
- [ ] Add Http transport layer
- [ ] Add script to generate resources
- [✓] Add @CRUD decorator
- [ ] Error handling
- [✓] Availability ping check
- [ ] Dynamic config
Organization
Stay in touch
License
@micro-nest is MIT licensed.