Code Monkey home page Code Monkey logo

nestcloud's Introduction

NestCloud

NestCloud is a Node.js micro-service solution, writing by Typescript language and Nest.js framework.

NPM Version Package License NPM Downloads Travis Linux Coverage Backers on Open Collective Sponsors on Open Collective

Install

$ npm install @nestcloud/cli -g

The NestCloud CLI is a command-line interface tool that helps you to initialize your NestCloud applications.

Read more here

Quick Start

CLI

$ nestcloud new nestcloud-app -t consul-app
$ nestcloud new nestcloud-app -t etcd-app

Starter

nestcloud-consul-starter

nestcloud-etcd-starter

Examples

nestcloud-typeorm-example

nestcloud-grpc-example

nestcloud-kubernetes-example

Components

Consul module.

Etcd module.

Kubernetes client module.

Get local configurations.

Get & watch remote configurations from Consul KV, Etcd or Kubernetes ConfigMap.

Service registration and service discovery

Software load balancers primary for rest calls.

A decorator and loadbalance http client.

A loadbalance grpc client.

A API proxy module.

A job scheduler that supports distributed and decorator.

Logger module based on [email protected]

Who used

Stay in touch

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

License

NestCloud is MIT licensed.

nestcloud's People

Contributors

dependabot[bot] avatar fabiofdsantos avatar monkeywithacupcake avatar reinaldooli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nestcloud's Issues

Config package does not expose Config class as stated in documentation

Hi,

First of all thanks for all the work awesome stuff.

But I have noticed that the documentation and actual packages are out of sync. In this case @nestcloud/config.

It does not export Config class as stated in documentation so it cant be properly injected. Is this a bug because the documentation has Config class in the exports and I have checked and could not find it in exports.

Release 0.7.4 not published on NPM (latest nor beta/next)

While debugging some missing GRPC options for client credentials I noticed that the latest on NPM is 0.6.11 but in the repo it is 0.7.4. From #19 it indicates as beta release but isn't published as beta neither on NPM.

Are there plans to publish this release as beta/next or being postponed until release is stable?

Can not initialize ServiceModule

[System Information]
OS Version : macOS Catalina
NodeJS Version : v10.0.0
YARN Version : 1.22.1

[Nest CLI]
Nest CLI Version : 7.1.4

[Nest Platform Information]
platform-express version : 7.4.2
microservices version : 7.4.2
terminus version : 7.0.1
testing version : 7.4.2
common version : 7.4.2
core version : 7.4.2

I just cloned the nestcloud-grpc-example then upgraded all the nest-cloud modules to the latest versions.
but unfortunately, it does not work even if I did not upgrade the version of the modules.
here is my terminal logs
image

服务的注册时机

服务的注册时机是不是不太妥当, 如果有模块在onModuleInit有阻塞,比如数据库链接,这是时候服务是不可用的,因为还没有 listen,但服务在模块初始化就注册上了

Issue with consul loading correct config in Kubernetes

When I deploy my services on kubernetes, consul keeps loading on port 127.0.0.1:8500 even after updating my consul option in bootstrap.yaml file.

Screen Shot 2020-04-21 at 13 58 23

I'm pinching my hair out. Here is my config.yaml

consul:
  host: consul-server-bootstrap
  port: 8500
config:
  key: ${{ service.name }}
service:
  discoveryHost: services-tenant.default.svc.cluster.local
  healthCheck:
    timeout: 1s
    interval: 10s
    tcp: ${{ service.discoveryHost }}:${{ service.port }}
  maxRetry: 5
  retryInterval: 5000
  name: service
  port: 50090
loadbalance:
  ruleCls: RandomRule
logger:
  level: info
  transports:
    - transport: console
      colorize: true
      datePattern: YYYY-MM-DD h:mm:ss
      label: ${{ service.name }}

Please any help would be great

Requesting a proper microservices communication example

Hi @miaowing,

Thank you for providing such a great collection of tools for building microservices with NestJS. What I am looking for is a sample to understand how the NestCloud works with few microservices and the way those communicate with each other using Consul. Can you please put together something like below.

Service A - has a method getHello returns 'Hello from A'
Service B - has a method getHello returns 'Hello from B'
Service C - has a method getHello returns 'Hello from C'

Service D - consume all A, B, C services using Service discovery and provide a REST interface(API) to outside.

I am trying to understand how this works with the discovery service.

Please add a sample.

Thanks

请问如何在getServiceNodeInfo函数中获得Post返回的数据做二次加工,同时对Post传递参数,在返回到controller中

import { Injectable, Body, Inject } from "@nestjs/common";
import { Loadbalanced } from "@nestcloud/loadbalance";
import { Get, ost } from "@nestcloud/feign";
// import { AXIOS_INSTANCE_PROVIDER } from "@nestcloud/http/http.constants";

@Injectable()
// enable loadbalance supports, need import @nestcloud/loadbalance module at first.
@Loadbalanced("service-test")
export class ServiceNodeClient {
  // constructor(@Inject(AXIOS_INSTANCE_PROVIDER) private readonly httpService: HttpClient) {}
  // constructor() {}

  @Post("/service-test/get-service-test-info-by-caller-test")
  async getServiceNodeInfo() {}

  @Get("http://test.com/users")
  // disable loadbalance supports.
  @Loadbalanced(false)
  getRemoteUsers() {}
}

请问如何在getServiceNodeInfo函数中获得Post返回的数据做二次加工,在返回到controller中,同时对Post传递参数

Error with @nestcloud/config

After updating the @nestcloud/config package as well at the @nestcloud/boot modules, I noticed some API changes, where dependencies' are now inject` in some cases and the constants for NEST_CONSUL has been changed to CONSUL

However, the issues I'm having with the config package is with these interfaces,

ERROR in libs/core/src/modules/subscription-base.class.ts:5:28
TS2307: Cannot find module '@nestcloud/config/etcd-config' or its corresponding type declarations.
    3 | import { Logger } from '@nestjs/common';
    4 | import { NatsPubSub } from '@moonwalker/graphql-nats-subscriptions';
  > 5 | import { EtcdConfig } from '@nestcloud/config/etcd-config';
      |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    6 | 
    7 | export class SubscriptionBaseClass {
    8 |     public pubsub: MQTTPubSub | NatsPubSub;

ERROR in libs/core/src/modules/subscription-base.provider.ts:5:28
TS2307: Cannot find module '@nestcloud/config/etcd-config' or its corresponding type declarations.
    3 | import { Injectable, Logger, OnModuleDestroy, OnModuleInit, Scope } from '@nestjs/common';
    4 | import { NatsPubSub } from '@moonwalker/graphql-nats-subscriptions';
  > 5 | import { EtcdConfig } from '@nestcloud/config/etcd-config';
      |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    6 | import { InjectConfig } from '@nestcloud/config';
    7 | 
    8 | @Injectable({

ERROR in libs/core/src/services/configs/cache-store-config.service.ts:4:28
TS2307: Cannot find module '@nestcloud/config/etcd-config' or its corresponding type declarations.
    2 | import { InjectConfig } from '@nestcloud/config';
    3 | import { Etcd3 } from 'etcd3';
  > 4 | import { EtcdConfig } from '@nestcloud/config/etcd-config';
      |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    5 | import redisStore from 'cache-manager-redis-store';
    6 | import * as redis from 'redis';
    7 | 


ERROR in libs/core/src/services/configs/jwt-config.service.ts:2:10
TS2305: Module '"../../../../../node_modules/@nestcloud/config"' has no exported member 'ConsulConfig'.
    1 | import { Injectable, Logger } from '@nestjs/common';
  > 2 | import { ConsulConfig, InjectConfig } from '@nestcloud/config';
      |          ^^^^^^^^^^^^
    3 | import { JwtModuleOptions, JwtOptionsFactory } from '@nestjs/jwt';
    4 | 
    5 | @Injectable()

ERROR in libs/core/src/services/configs/mongo-config.service.ts:3:28
TS2307: Cannot find module '@nestcloud/config/etcd-config' or its corresponding type declarations.
    1 | import { Injectable } from '@nestjs/common';
    2 | import { InjectConfig } from '@nestcloud/config';
  > 3 | import { EtcdConfig } from '@nestcloud/config/etcd-config';
      |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    5 | import { ConsulDatabaseConfig } from '@src/common';

The rule RandomRule is not exist

I have this issue when using [email protected] and [email protected]

    at Timeout._onTimeout (/Users/�username/Desktop/Projects/nest-cqrs-auth/node_modules/@nestcloud/loadbalance/loadbalance.js:90:45)
    at listOnTimeout (internal/timers.js:551:17)
    at processTimers (internal/timers.js:494:7)
(Use `node --trace-warnings ...` to show where the warning was created```

"nest build" fails when using Fastify

I am using nestcloud boot and consul.
When using Nest with Fastify we cannot build an app that uses nestcloud:

$ npm run build

> [email protected] prebuild /home/trenduser/dev/git/new-product-search/b2b-product-search-service
> rimraf dist


> [email protected] build /home/trenduser/dev/git/new-product-search/b2b-product-search-service
> nest build

node_modules/@nestcloud/common/interfaces/proxy.interface.d.ts:1:35 - error TS2307: Cannot find module 'express' or its corresponding type declarations.

1 import { Request, Response } from 'express';
                                    ~~~~~~~~~
node_modules/@nestcloud/common/utils/provider.util.d.ts:10:71 - error TS2307: Cannot find module 'typeorm' or its corresponding type declarations.

10     inject: (string | Function | import("@nestjs/common").Type<import("typeorm").Connection>)[];
                                                                         ~~~~~~~~~
node_modules/@nestcloud/common/utils/provider.util.d.ts:15:71 - error TS2307: Cannot find module 'typeorm' or its corresponding type declarations.

15     inject: (string | Function | import("@nestjs/common").Type<import("typeorm").Connection>)[];
                                                                      ~~~~~~~~~

As a workaround I installed express and typeorm, but I don't believe this is the correct approach.

English documenation

Hello, we a looking into using this framework in our next project. Is there any plans for English documentation ?

TypeError: Cannot read property 'choose' of undefined

TypeError: Cannot read property 'choose' of undefined

My app.module.ts like this:
LoggerModule.register(),
BootModule.register(context, filename),
ConsulModule.register({ dependencies: [NEST_BOOT] }),
LoadbalanceModule.register({ dependencies: [NEST_BOOT] }),
ConfigModule.register({ dependencies: [NEST_BOOT, NEST_CONSUL] }),
ProxyModule.register({ dependencies: [NEST_BOOT] }),

How to contribute?

I am a nestjs developer, and working on a lot of micro-service system. This nest micro-service solution is very awesome, so I am looking forward to contribute to this project.

Looking forward to your reply ❤️

Consul service discovery failure

I am having troubles with microservice health checks in my consul docker setup, which i believe is a symptom of failure in service discovery as i only have one server in my registry.

Below is consul list of members from inside the docker container.

/ # consul members
Node          Address          Status  Type    Build  Protocol  DC   Segment
7b1edb14a647  172.19.0.6:8301  alive   server  1.7.4  2         dc1  <all>
/ #

Consul container logs repeat the same error below for all the microservices:

consul | 2020-06-16T12:19:11.087Z [WARN]  agent: Check socket connection failed: check=service:ffa44b66c4869601c04abdbea6dc5be5 error="dial tcp 172.19.0.6:50044: connect: connection refused"

I am using docker-compose v.3.2 to create a network for containers.

This is a consul service definition

  consul:
    container_name: consul
    ports:
      - '8400:8400'
      - '8500:8500'
      - '8600:53/udp'
    image: consul
    command: ['agent', '-server', '-bootstrap', '-ui', '-client', '0.0.0.0']

Microservice definition

  service-notification:
    build:
      context: .
      dockerfile: apps/service-notification/Dockerfile
      args:
        NODE_ENV: development
    depends_on:
      - consul
    image: 'service-notification:latest'
    restart: always
    environment:
      - CONSUL_HOST=consul
    ports:
      - '50044:50044'

I am using CONSUL_HOST env variable to pass in correct host url.

Consul config for the microservice

  consul:
    host: ${{CONSUL_HOST}}
    port: 8500
  service:
    discoveryHost: service-notification
    healthCheck:
      timeout: 1s
      interval: 10s
      tcp: ${{ service.discoveryHost }}:${{ service.port }}
    maxRetry: 5
    retryInterval: 5000
    tags: ["v1.0.0", "microservice"]
    name: io.ultimatebackend.srv.notification
    port: 50044

My conclusion so far is that consul server container fails to reach the agents somehow. But i don't know why and i feel like i am missing some obvious peace of consul structure. Please advise.

@nestcloud/feign 0.3.15包引用

feign.module.ts中引用了import { NEST_CONSUL_CONFIG_PROVIDER } from '../common',应该是import { NEST_CONSUL_CONFIG_PROVIDER } from '@nestcloud/common';

迭代

请问这个项目是已经停止维护了吗

Config not propagating to Consul ?

Hi,

I managed to get it bootstraping now, but I have a problem that it's trying to connect to 127.0.0.1 for consul but i have the BootModule loaded with my config.yaml.

It is supposed to pick this up right?

Hey is there a slack or discord service for nestcloud - just for future reference?

Here is a capture of the screen

image

Example for etcd for service discovery ?

Hi,

I would like to see an example of a service discovery using etcd.

I checked some samples but I don't fully understand it.

How do you register a service using etcd ?

How do you get the IP etc that was registered from another service ?

Any other examples that I have missed ?

Also any specific english documentation ?

Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.