Refactor database environment variable usage across workflows and application code
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 3m53s
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 3m53s
- Updated Gitea workflows to standardize on `DB_NAME` instead of `DB_DATABASE` for database name references. - Modified deployment, backup, reset, and restore workflows to ensure consistent environment variable usage. - Removed dotenv dependency and preload script, transitioning to environment variable management directly in scripts. - Adjusted application code to utilize `DB_NAME` for database connections and logging. - Enhanced README to reflect changes in environment variable configuration and usage. - Cleaned up package.json scripts to remove unnecessary preload references.
This commit is contained in:
10
server.ts
10
server.ts
@@ -21,9 +21,6 @@ import healthRouter from './src/routes/health';
|
||||
import { errorHandler } from './src/middleware/errorHandler';
|
||||
import { startBackgroundJobs } from './src/services/backgroundJobService';
|
||||
|
||||
// Environment variables are now loaded by the `tsx` command in package.json scripts.
|
||||
// This ensures the correct .env file is used for development vs. testing.
|
||||
|
||||
// --- START DEBUG LOGGING ---
|
||||
// Log the database connection details as seen by the SERVER PROCESS.
|
||||
// This will confirm if the `--env-file` flag is working as expected.
|
||||
@@ -32,7 +29,7 @@ logger.info(` NODE_ENV: ${process.env.NODE_ENV}`);
|
||||
logger.info(` Host: ${process.env.DB_HOST}`);
|
||||
logger.info(` Port: ${process.env.DB_PORT}`);
|
||||
logger.info(` User: ${process.env.DB_USER}`);
|
||||
logger.info(` Database: ${process.env.DB_DATABASE}`);
|
||||
logger.info(` Database: ${process.env.DB_NAME}`);
|
||||
|
||||
// Query the users table to see what the server process sees on startup.
|
||||
// Corrected the query to be unambiguous by specifying the table alias for each column.
|
||||
@@ -101,8 +98,9 @@ const requestLogger = (req: Request, res: Response, next: NextFunction) => {
|
||||
app.use(requestLogger); // Use the logging middleware for all requests
|
||||
|
||||
// --- Security Warning ---
|
||||
if ((process.env.JWT_SECRET || 'your_super_secret_jwt_key_change_this') === 'your_super_secret_jwt_key_change_this') {
|
||||
logger.warn('Security Warning: JWT_SECRET is using a default, insecure value. Please set a strong secret in your .env file.');
|
||||
if (!process.env.JWT_SECRET) {
|
||||
logger.error('CRITICAL: JWT_SECRET is not set. The application cannot start securely.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// --- API Routes ---
|
||||
|
||||
Reference in New Issue
Block a user