Fix env path for Nestjs

This commit is contained in:
Philipinho
2024-03-23 00:08:44 +00:00
parent a40ba4b41e
commit f1d7ffb9dd
3 changed files with 7 additions and 2 deletions

View File

@ -1,8 +1,7 @@
import { DataSource } from 'typeorm';
import * as dotenv from 'dotenv';
import { NamingStrategy } from './naming-strategy';
import * as path from 'path';
const envPath = path.resolve(process.cwd(), '..', '..', '.env');
import { envPath } from '../helpers/utils';
dotenv.config({ path: envPath });

View File

@ -1,5 +1,9 @@
import * as path from 'path';
export function generateHostname(name: string): string {
let hostname = name.replace(/[^a-z0-9]/gi, '').toLowerCase();
hostname = hostname.substring(0, 30);
return hostname;
}
export const envPath = path.resolve(process.cwd(), '..', '..', '.env');

View File

@ -2,6 +2,7 @@ import { Global, Module } from '@nestjs/common';
import { EnvironmentService } from './environment.service';
import { ConfigModule } from '@nestjs/config';
import { validate } from './environment.validation';
import { envPath } from '../../helpers/utils';
@Global()
@Module({
@ -9,6 +10,7 @@ import { validate } from './environment.validation';
ConfigModule.forRoot({
isGlobal: true,
expandVariables: true,
envFilePath: envPath,
validate,
}),
],