Skip to content
Snippets Groups Projects
configuration.service.ts 1.08 KiB
Newer Older
import { Logger } from '@nestjs/common';
import * as dotenv from 'dotenv';
import { config } from './config';
import { configProd } from './config.prod';
Hugo SUBTIL's avatar
Hugo SUBTIL committed
import { configDev } from './config.dev';
export class ConfigurationService {
  constructor() {
    // Initializing conf with values from var env
    if (process.env.NODE_ENV && process.env.NODE_ENV === 'production') {
      this._config.templates = config.templates; // Add mail templates
      Logger.log('App started with production conf', 'ConfigurationService');
    } else if (process.env.NODE_ENV && process.env.NODE_ENV === 'dev') {
Hugo SUBTIL's avatar
Hugo SUBTIL committed
      this._config = configDev;
      this._config.templates = config.templates; // Add mail templates
Hugo SUBTIL's avatar
Hugo SUBTIL committed
      Logger.log('App started with dev conf', 'ConfigurationService');
Hugo SUBTIL's avatar
Hugo SUBTIL committed
      Logger.log('App started with local conf', 'ConfigurationService');
  public isLocalConf(): boolean {
    return process.env.NODE_ENV === 'local';
  }

  get config() {
    return this._config;
  }