Files
trainingstagebuch/backend/config.js
Torsten Schulz (local) f7eff0bcb7 Enhance error handling and logging in backend controllers and services
This commit improves error handling in various controllers, including diaryNoteController, memberNoteController, and permissionController, by adding console error logging for better debugging. Additionally, it updates the diaryService and teamDocumentService to enhance functionality and maintainability. The config.js file is also updated to ensure proper configuration for the development environment. These changes contribute to a more robust and user-friendly application.
2025-11-11 11:36:47 +01:00

41 lines
1.1 KiB
JavaScript

import dotenv from 'dotenv';
import path from 'path';
import { fileURLToPath } from 'url';
// Ensure .env is loaded from the backend folder (not dependent on process.cwd())
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
dotenv.config({ path: path.resolve(__dirname, '.env') });
const isTestEnv = process.env.NODE_ENV === 'test';
const baseConfig = {
username: process.env.DB_USER || 'root',
password: process.env.DB_PASSWORD || 'hitomisan',
database: process.env.DB_NAME || 'trainingdiary',
host: process.env.DB_HOST || 'localhost',
dialect: process.env.DB_DIALECT || 'mysql',
define: {
freezeTableName: true,
underscored: true,
underscoredAll: true,
},
logging: false,
storage: process.env.DB_STORAGE,
};
if (isTestEnv) {
baseConfig.username = 'sqlite';
baseConfig.password = '';
baseConfig.database = 'sqlite';
baseConfig.host = 'localhost';
baseConfig.dialect = 'sqlite';
baseConfig.storage = process.env.DB_STORAGE || ':memory:';
}
if (baseConfig.dialect === 'sqlite' && !baseConfig.storage) {
baseConfig.storage = ':memory:';
}
export const development = baseConfig;