📝Configuration

The module provides a service for configuring the application.

Imports

import { ConfigurationService } from 'niro-health';

Method of Use

To use this module, you need to inject it into the desired service.

import { Module } from '@nestjs/common';
import {
  ConfigurationService,
  StringExService,
  ValidatorRegexpService,
} from 'niro-health';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: 'IConfigurationService',
      useClass: ConfigurationService,
    },
    {
      provide: 'IValidatorRegexpService',
      useClass: ValidatorRegexpService,
    },
    {
      provide: 'IStringExService',
      useClass: StringExService,
    },
  ],
})
export class AppModule {}

Injecting the module into our service.

import { Inject, Injectable } from '@nestjs/common';
import type { IConfigurationService } from 'niro-health';

@Injectable()
export class AppService {
  constructor(
    @Inject('IConfigurationService')
    private readonly configurationService: IConfigurationService,
  ) {}

  async isDev() {
    return this.configurationService.isDev;
  }
}

With dependencies

You will need to inject the following interfaces.

Interface
Service

IValidatorRegexpService

Link to Service documentation

IStringExService

Link to Service documentation

Properties

Property
Scope
Description

_NODE_ENV

private

The node environment to use.

_VERSION

private

The application version.

_API_URI

private

The application back-end API URI.

_WEBAPP_URI

private

The application front-end API URI.

_PORT

private

The port to use.

_DATABASE_URL

private

The database URL.

_DB_PORT

private

The database port.

_DB_USERNAME

private

The database username.

_DB_PASSWORD

private

The database password.

_DB_DATABASE_NAME

private

The database name.

_MONGODB_USERNAME

private

The mongodb username.

_MONGODB_PASSWORD

private

The mongodb password.

_MONGODB_HOST

private

The mongodb host.

_MONGODB_PORT

private

The mongodb port.

_MONGODB_NAME

private

The mongodb name.

_MONGODB_GRIDFS_NAME

private

The mongodb gridfs name.

_MONGODB_CONNECTION_SSL

private

The mongodb connection ssl.

_MONGODB_PROJECT_NAME

private

The mongodb project name.

_REDIS_HOST

private

The redis host.

_REDIS_PORT

private

The redis port.

_REDIS_PASSWORD

private

The redis password.

_BULL_BOARD_USERNAME

private

The bull board username.

_BULL_BOARD_PASSWORD

private

The bull board password.

_CRON_TIMEZONE

private

The cron timezone.

_CRYPTO_PASSWORD

private

The crypto password.

_MASTER_KEY

private

The master key used to authenticate the routes.

_JWT_SECRET

private

The secret for Json Web Token.

_COOKIE_SECRET

private

The secret for the cookies.

_SESSION_SECRET

private

The secret for the sessions.

_AXIOS_URI

private

The URI for the axios requests.

_AXIOS_AUTHORIZATION

private

The authorization for the axios requests.

_AWS_ACCESS_KEY_ID

private

The AWS access key id.

_AWS_SECRET_ACCESS_KEY

private

The AWS secret access key.

_SMTP_HOST

private

The SMTP host.

_SMTP_PORT

private

The SMTP port.

_SMTP_SECURE

private

The SMTP secure.

_SMTP_USERNAME

private

The SMTP username.

_SMTP_PASSWORD

private

The SMTP password.

@ENVS

static

The environment variables.

@VARIABLES

static

The variables.

Methods

Method
Scope
Description

_check

private

Check the environment variables.

_load

private

Load environment variables

_transformBoolean

private

Transform string to boolean.

_compress

private

Compress the value to string.

_decompress

private

Decompress the string to original value.

get

public

Get the value from the environment.

register

public

Set the value to the environment.

unregister

public

Delete the value from the environment.

getVariable

public

Get the value from the variable.

setVariable

public

Set the value to the variable.

delVariable

public

Delete the value from the variable.

get NODE_ENV

public

Returns the node environment.

get VERSION

public

Returns the version of the application.

get API_URI

public

Returns the uri of the back-end.

get WEBAPP_URI

public

Returns the uri of the front-end.

get PORT

public

Returns the port of the application.

get DATABASE_URL

public

Returns the url of the database.

get DB_PORT

public

Returns the port of the database.

get DB_USERNAME

public

Returns the username of the database.

get DB_PASSWORD

public

Returns the password of the database.

get DB_DATABASE_NAME

public

Returns the name of the database.

get MONGODB_USERNAME

public

Returns the username of the mongodb.

get MONGODB_PASSWORD

public

Returns the password of the mongodb.

get MONGODB_HOST

public

Returns the host of the mongodb.

get MONGODB_PORT

public

Returns the port of the mongodb.

get MONGODB_NAME

public

Returns the name of the mongodb.

get MONGODB_GRIDFS_NAME

public

Returns the name of the gridfs in mongodb.

get MONGODB_CONNECTION_SSL

public

Returns the ssl connection of the mongodb.

get MONGODB_PROJECT_NAME

public

Returns the project name of the mongodb.

get REDIS_HOST

public

Returns the host of the redis.

get REDIS_PORT

public

Returns the port of the redis.

get REDIS_PASSWORD

public

Returns the password of the redis.

get BULL_BOARD_USERNAME

public

Returns the username of the bull board.

get BULL_BOARD_PASSWORD

public

Returns the password of the bull board.

get CRON_TIMEZONE

public

Returns the timezone of the cron.

get CRYPTO_PASSWORD

public

Returns the password of the crypto.

get MASTER_KEY

public

Returns the master keys.

get JWT_SECRET

public

Returns the secret of the Json Web Token.

get COOKIE_SECRET

public

Returns the secret of the cookies.

get SESSION_SECRET

public

Returns the secret of the sessions.

get AXIOS_URI

public

Returns the uri of the axios requests.

get AXIOS_AUTHORIZATION

public

Returns the authorization of the axios requests.

get AWS_ACCESS_KEY_ID

public

Returns the access key id of the aws.

get AWS_SECRET_ACCESS_KEY

public

Returns the secret of the access key in aws.

get SMTP_HOST

public

Returns the host of the smtp.

get SMTP_PORT

public

Returns the port of the smtp.

get SMTP_SECURE

public

Returns the secure of the smtp.

get SMTP_USERNAME

public

Returns the username of the smtp.

get SMTP_PASSWORD

public

Returns the password of the smtp.

get isDev

public

Check if the environment is development.

get isProd

public

Check if the environment is production.

get isTest

public

Check if the environment is test.

get mongoDB

public

Returns the mongoDB configuration.

get redis

public

Returns the redis configuration.

get bullBoard

public

Returns the bull board configuration.

get secrets

public

Returns the secrets of the application (crypto, master key, jwt, cookie, session).

get axios

public

Returns the axios configuration.

get aws

public

Returns the aws configuration.

get smtp

public

Returns the smtp configuration.

Last updated