BugFixes bzgl. Observables, Logging Anpassungen, Endpunkt hardening, dotenv-flow usage
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import { MiddlewareConsumer, Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { PassportModule } from '@nestjs/passport';
|
||||
import * as dotenv from 'dotenv';
|
||||
import fs from 'fs-extra';
|
||||
import { WinstonModule, utilities as nestWinstonModuleUtilities } from 'nest-winston';
|
||||
import * as winston from 'winston';
|
||||
import { AiModule } from './ai/ai.module';
|
||||
@@ -16,46 +14,48 @@ import { ListingsModule } from './listings/listings.module';
|
||||
import { LogController } from './log/log.controller';
|
||||
import { LogModule } from './log/log.module';
|
||||
|
||||
import dotenvFlow from 'dotenv-flow';
|
||||
import { EventModule } from './event/event.module';
|
||||
import { JwtStrategy } from './jwt.strategy';
|
||||
import { MailModule } from './mail/mail.module';
|
||||
import { PaymentModule } from './payment/payment.module';
|
||||
import { RequestDurationMiddleware } from './request-duration/request-duration.middleware';
|
||||
import { SelectOptionsModule } from './select-options/select-options.module';
|
||||
import { UserModule } from './user/user.module';
|
||||
import { EventModule } from './event/event.module';
|
||||
// const __filename = fileURLToPath(import.meta.url);
|
||||
// const __dirname = path.dirname(__filename);
|
||||
|
||||
function loadEnvFiles() {
|
||||
// Determine which additional env file to load
|
||||
let envFilePath = '';
|
||||
const host = process.env.HOST_NAME || '';
|
||||
// function loadEnvFiles() {
|
||||
// // Determine which additional env file to load
|
||||
// let envFilePath = '';
|
||||
// const host = process.env.HOST_NAME || '';
|
||||
|
||||
if (host.includes('localhost')) {
|
||||
envFilePath = '.env.local';
|
||||
} else if (host.includes('dev.bizmatch.net')) {
|
||||
envFilePath = '.env.dev';
|
||||
} else if (host.includes('www.bizmatch.net') || host.includes('bizmatch.net')) {
|
||||
envFilePath = '.env.prod';
|
||||
}
|
||||
// if (host.includes('localhost')) {
|
||||
// envFilePath = '.env.local';
|
||||
// } else if (host.includes('dev.bizmatch.net')) {
|
||||
// envFilePath = '.env.dev';
|
||||
// } else if (host.includes('www.bizmatch.net') || host.includes('bizmatch.net')) {
|
||||
// envFilePath = '.env.prod';
|
||||
// }
|
||||
|
||||
// Load the additional env file if it exists
|
||||
if (fs.existsSync(envFilePath)) {
|
||||
dotenv.config({ path: envFilePath });
|
||||
console.log(`Loaded ${envFilePath} file`);
|
||||
} else {
|
||||
console.log(`No additional .env file found for HOST_NAME: ${host}`);
|
||||
}
|
||||
// // Load the additional env file if it exists
|
||||
// if (fs.existsSync(envFilePath)) {
|
||||
// dotenv.config({ path: envFilePath });
|
||||
// console.log(`Loaded ${envFilePath} file`);
|
||||
// } else {
|
||||
// console.log(`No additional .env file found for HOST_NAME: ${host}`);
|
||||
// }
|
||||
|
||||
// Load the .env file
|
||||
dotenv.config();
|
||||
console.log('Loaded .env file');
|
||||
// Output all loaded environment variables
|
||||
console.log('Loaded environment variables:');
|
||||
console.log(JSON.stringify(process.env, null, 2));
|
||||
}
|
||||
// // Load the .env file
|
||||
// dotenv.config();
|
||||
// console.log('Loaded .env file');
|
||||
// // Output all loaded environment variables
|
||||
// console.log('Loaded environment variables:');
|
||||
// console.log(JSON.stringify(process.env, null, 2));
|
||||
// }
|
||||
|
||||
loadEnvFiles();
|
||||
//loadEnvFiles();
|
||||
dotenvFlow.config();
|
||||
console.log('Loaded environment variables:');
|
||||
console.log(JSON.stringify(process.env, null, 2));
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({ isGlobal: true }),
|
||||
@@ -65,7 +65,9 @@ loadEnvFiles();
|
||||
transports: [
|
||||
new winston.transports.Console({
|
||||
format: winston.format.combine(
|
||||
winston.format.timestamp(),
|
||||
winston.format.timestamp({
|
||||
format: 'YYYY-MM-DD hh:mm:ss.SSS A',
|
||||
}),
|
||||
winston.format.ms(),
|
||||
nestWinstonModuleUtilities.format.nestLike('Bizmatch', {
|
||||
colors: true,
|
||||
|
||||
Reference in New Issue
Block a user