A NodeJS micro-service solution based on Consul, writing by Typescript language and NestJS framework.
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
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.
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 {
}
You can use the NestCloud-Starter start your project quickly.
- Author - NestCloud
NestCloud is MIT licensed.