.env refactoring. Not sure whether it works
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import 'dotenv/config';
|
||||
import dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
|
||||
// Load env from project root
|
||||
dotenv.config({ path: path.join(__dirname, '../../.env') });
|
||||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
import authRoutes from './routes/auth';
|
||||
@@ -12,7 +16,6 @@ import bcrypt from 'bcryptjs';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3';
|
||||
import BetterSqlite3 from 'better-sqlite3';
|
||||
import path from 'path';
|
||||
|
||||
const app = express();
|
||||
|
||||
@@ -20,8 +23,13 @@ const app = express();
|
||||
// Ensure a default admin user exists on startup
|
||||
// -------------------------------------------------------------------
|
||||
async function ensureAdminUser() {
|
||||
const adminEmail = process.env.ADMIN_EMAIL || 'admin@gymflow.ai';
|
||||
const adminPassword = process.env.ADMIN_PASSWORD || 'admin123';
|
||||
const adminEmail = process.env.ADMIN_EMAIL;
|
||||
const adminPassword = process.env.ADMIN_PASSWORD;
|
||||
|
||||
if (!adminEmail || !adminPassword) {
|
||||
console.warn('⚠️ ADMIN_EMAIL or ADMIN_PASSWORD not set in .env. Skipping default admin creation.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Use the singleton prisma client
|
||||
const prisma = (await import('./lib/prisma')).default;
|
||||
|
||||
Reference in New Issue
Block a user