Skip to content

Dn9x/nestcloud

 
 

Repository files navigation

NestCloud

NPM Version Package License NPM Downloads Travis Linux Coverage

A NodeJS micro-service solution, writing by Typescript language and NestJS framework that based on Consul or Kubernetes.

Install

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

Docs

中文文档

Examples

nestcloud-typeorm-example

nestcloud-grpc-example

nestcloud-kubernetes-example

Starter

You can use the NestCloud-Starter start your project quickly.

Components

Consul module.

Memcached module.

Kubernetes client module.

Get local configurations.

Get & watch remote configurations from Consul KV 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 winston@2.x

Validate request params.

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] }),
        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

License

NestCloud is MIT licensed.

About

A NodeJS micro-service solution, writing by Typescript language and NestJS framework.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 98.3%
  • JavaScript 1.7%