A NodeJS micro-service solution, writing by Typescript language and NestJS framework that based on Consul or Kubernetes.
npm install --save @nestcloud/core @nestcloud/common @nestcloud/boot @nestcloud/consul @nestcloud/service @nestcloud/config @nestcloud/loadbalance @nestcloud/feign @nestcloud/logger @nestcloud/schedule
You can use the NestCloud-Starter start your project quickly.
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.
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 {
}
- Author - NestCloud
NestCloud is MIT licensed.