Skip to content

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

License

Notifications You must be signed in to change notification settings

guofeifei123/nestcloud

 
 

Repository files navigation

NestCloud

NPM Version Package License NPM Downloads Travis Linux Coverage

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

Install

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

Docs

中文文档

Components

Get local configurations and environment values when the app bootstrap.

Consul module.

Get & watch configurations from Consul KV.

Register & cancel register service, discovery other service.

Software load balancers primary for rest calls.

A http client that supports decorator and loadbalance.

A grpc client that supports loadbalance.

A API proxy module.

Memcached module.

A job scheduler that supports distributed and decorator.

Logger module based on [email protected]

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 } from '@nestcloud/common';
import { BootModule } from '@nestcloud/boot';
import { ConsulModule } from '@nestcloud/consul';
import { ConsulConfigModule } from '@nestcloud/consul-config';
import { ConsulServiceModule } from '@nestcloud/consul-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] }),
        ConsulConfigModule.register({ dependencies: [NEST_BOOT] }),
        ConsulServiceModule.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 {
}

Starter

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

Samples

Samples

Who used

焱融云

Stay in touch

License

NestCloud is MIT licensed.

About

A NodeJS micro-service solution based on Consul, 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%