refactor: improve service layer logging and configuration

- Change email service logging from console.log to console.warn for better visibility
- Update mailgun and couchdb configuration with improved error handling
- Enhance database seeder with better logging and error management
- Improve service factory patterns for better testability
This commit is contained in:
William Valentin
2025-09-07 15:22:04 -07:00
parent 58a4988b58
commit 172bb2bd74
4 changed files with 36 additions and 48 deletions

View File

@@ -2,16 +2,17 @@
// This file determines whether to use mock localStorage or real CouchDB
import { CouchDBService as MockCouchDBService } from './couchdb';
import { getEnvVar, isTest } from '../utils/env';
// Environment detection
const isProduction = () => {
// Check if we're in a Docker environment or if CouchDB URL is configured
const env = (import.meta as { env?: Record<string, string> }).env || {};
const couchdbUrl =
env.VITE_COUCHDB_URL ||
(typeof process !== 'undefined' ? process.env.VITE_COUCHDB_URL : null) ||
(typeof process !== 'undefined' ? process.env.COUCHDB_URL : null);
// Always use mock service in test environment
if (isTest()) {
return false;
}
// Check if we're in a Docker environment or if CouchDB URL is configured
const couchdbUrl = getEnvVar('VITE_COUCHDB_URL') || getEnvVar('COUCHDB_URL');
return !!couchdbUrl && couchdbUrl !== 'mock';
};