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


Keywords
cloud-native-microservices, consul, decorators, etcd, kubernetes, microservice, nest, typescript
License
MIT
Install
npm install @nestcloud/brakes@0.7.17

Documentation

NestCloud

NPM Version Package License NPM Downloads Travis Linux Coverage Financial Contributors on Open Collective

NestCloud is a NodeJS micro-service solution, writing by Typescript language and NestJS framework. Consul, Etcd or Kubernetes all can be the service discovery center for NestCloud.

Install

You need install the packages by the service discovery that which you select.

Consul Backend

$ npm install --save @nestcloud/core
$ npm install --save @nestcloud/common
$ npm install --save @nestcloud/boot 
$ npm install --save @nestcloud/consul 
$ npm install --save @nestcloud/service 
$ npm install --save @nestcloud/config 
$ npm install --save @nestcloud/loadbalance 
$ npm install --save @nestcloud/feign 
$ npm install --save @nestcloud/logger 

Etcd Backend

$ npm install --save @nestcloud/core
$ npm install --save @nestcloud/common
$ npm install --save @nestcloud/boot 
$ npm install --save @nestcloud/etcd 
$ npm install --save @nestcloud/service 
$ npm install --save @nestcloud/config 
$ npm install --save @nestcloud/loadbalance 
$ npm install --save @nestcloud/feign 
$ npm install --save @nestcloud/logger 

Kubernetes Backend

$ npm install --save @nestcloud/core
$ npm install --save @nestcloud/common
$ npm install --save @nestcloud/boot 
$ npm install --save @nestcloud/config 
$ npm install --save @nestcloud/loadbalance 
$ npm install --save @nestcloud/feign 
$ npm install --save @nestcloud/logger 
$ npm install --save @nestcloud/kubernetes 

Docs

中文文档

Examples

nestcloud-typeorm-example

nestcloud-grpc-example

nestcloud-kubernetes-example

Starter

nestcloud-consul-starter

nestcloud-etcd-starter

Components

Consul

Consul module.

Etcd

Etcd module.

Memcached

Memcached module.

Kubernetes

Kubernetes client module.

Boot

Get local configurations.

Config

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

Service

Service registration and service discovery

Loadbalance

Software load balancers primary for rest calls.

Feign

A decorator and loadbalance http client.

Grpc

A loadbalance grpc client.

Proxy

A API proxy module.

Schedule

A job scheduler that supports distributed and decorator.

Logger

Logger module based on winston@2.x

Validations

Validate request params.

Rbac

Role based access control.

Quick Start

main.ts

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { NestLogger } from '@nestcloud/logger';
import { NestCloud } from '@nestcloud/core';

async function bootstrap() {
    const app = NestCloud.create(await NestFactory.create(AppModule, {
        logger: new NestLogger({
            path: __dirname,
            filename: `config.yaml`
        }),
    }));

    await app.listen(NestCloud.global.boot.get('consul.service.port', 3000));
}

bootstrap();

app.module.ts

import { Module } from '@nestjs/common';
import { NEST_BOOT, NEST_LOADBALANCE, NEST_CONSUL } from '@nestcloud/common';
import { BootModule } from '@nestcloud/boot';
import { ConsulModule } from '@nestcloud/consul';
import { ConfigModule } from '@nestcloud/config';
import { ServiceModule } from '@nestcloud/service';
import { LoadbalanceModule } from '@nestcloud/loadbalance';
import { FeignModule } from '@nestcloud/feign';
import { LoggerModule } from '@nestcloud/logger';
import { TerminusModule } from '@nestjs/terminus';

@Module({
    imports: [
        LoggerModule.register(),
        BootModule.register(__dirname, `config.yaml`),
        ConsulModule.register({ dependencies: [NEST_BOOT] }),
        ConfigModule.register({ dependencies: [NEST_BOOT, NEST_CONSUL] }),
        ServiceModule.register({ dependencies: [NEST_BOOT, NEST_CONSUL] }),
        LoadbalanceModule.register({ dependencies: [NEST_BOOT] }),
        FeignModule.register({ dependencies: [NEST_BOOT, NEST_LOADBALANCE] }),
        TerminusModule.forRootAsync({
            useFactory: () => ({ endpoints: [{ url: '/health', healthIndicators: [] }] }),
        }),
    ]
})
export class AppModule {
}

Samples

Samples

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.