1.0.17 • Published 11 months ago

@micro-nest/common v1.0.17

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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.

1.0.17

11 months ago

1.0.16

12 months ago

1.0.15

12 months ago

1.0.14

12 months ago

1.0.13

12 months ago

1.0.12

12 months ago

1.0.11

12 months ago

1.0.10

12 months ago

1.0.9

12 months ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago