Something went wrong on our end
-
Hugo SUBTIL authoredHugo SUBTIL authored
configuration.service.ts 1.01 KiB
import { Logger } from '@nestjs/common';
import * as dotenv from 'dotenv';
import { config } from './config';
import { configProd } from './config.prod';
import { configDev } from './config.dev';
export class ConfigurationService {
private readonly _config;
constructor() {
// Initializing conf with values from var env
if (process.env.NODE_ENV && process.env.NODE_ENV === 'production') {
this._config = configProd;
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') {
this._config = configDev;
this._config.templates = config.templates; // Add mail templates
Logger.log('App started with dev conf', 'ConfigurationService');
} else {
this._config = config;
}
dotenv.config();
}
public isLocalConf(): boolean {
return process.env.NODE_ENV === 'local';
}
get config() {
return this._config;
}
}