0.0.27 • Published 1 year ago
@jrosadob/ms-config v0.0.27
@jrosadob/ms-config
Package dependencies
This package use:
$ npm i cloud-config-client
$ npm i @nestjs/config
How use
Install
$ npm i @jrosadob/ms-config
Sample .env
file
The rest of the configuration should be on the configuration server in yml format.
# Endpoint Config Server (Mandatory)
ENDPOINT=http://localhost:8901
# Application name (Mandatory)
CONFIG=ms-auth
# Environment (Optional)
LABEL=development
Use in main.ts
This sample show how use ConfigServer in main.ts
import { NestFactory } from '@nestjs/core'
import { Logger } from '@nestjs/common'
import { ConfigService, LoadConfig } from '@jrosadob/ms-config'
import { AppModule } from './app.module'
async function bootstrap() {
const configService = await LoadConfig()
const environment = configService.get('NODE_ENV').toUpperCase()
const nameApp = configService.getServer('app.name')
const portTcp = +configService.getServer('app.portTcp')
const portHttp = +configService.getServer('app.portHttp')
const app = await NestFactory.create(AppModule)
await app.startAllMicroservices()
await app.listen(portHttp)
Logger.log(
`Microservice ${nameApp}: HTTP(s) Listening on http://localhost:${portHttp}`,
'Bootstrap',
)
Logger.log(`Environment: ${environment}`, 'Bootstrap')
}
bootstrap()
Use in app.module.ts
Only, if ConfigService is used in main.ts
import { Module } from '@nestjs/common'
import { ConfigService } from '@jrosadob/ms-config'
@Module({
imports: [],
controllers: [],
providers: [ConfigService],
})
export class AppModule {}
If not use ConfigService in main.ts, your app.modele.ts shoudlbe:
0.0.27
1 year ago
0.0.20
1 year ago
0.0.21
1 year ago
0.0.22
1 year ago
0.0.23
1 year ago
0.0.24
1 year ago
0.0.25
1 year ago
0.0.18
1 year ago
0.0.19
1 year ago
0.0.26
1 year ago
0.0.17
1 year ago
0.0.14
1 year ago
0.0.15
1 year ago
0.0.16
1 year ago
0.0.12
1 year ago
0.0.11
1 year ago
0.0.10
1 year ago
0.0.9
1 year ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago