0.0.27 • Published 14 days ago

@jrosadob/ms-config v0.0.27

Weekly downloads
-
License
MIT
Repository
-
Last release
14 days ago

@jrosadob/ms-config

npm version

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

14 days ago

0.0.20

16 days ago

0.0.21

16 days ago

0.0.22

16 days ago

0.0.23

16 days ago

0.0.24

16 days ago

0.0.25

16 days ago

0.0.18

16 days ago

0.0.19

16 days ago

0.0.26

16 days ago

0.0.17

19 days ago

0.0.14

21 days ago

0.0.15

21 days ago

0.0.16

21 days ago

0.0.12

23 days ago

0.0.11

23 days ago

0.0.10

23 days ago

0.0.9

23 days ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago