Fix jwt-token
This commit is contained in:
@@ -5,22 +5,12 @@ if (process.env.NODE_ENV !== 'test') {
|
||||
require('dotenv').config();
|
||||
}
|
||||
|
||||
// Function to get current models (checks global models each time)
|
||||
function getCurrentModels() {
|
||||
if (process.env.NODE_ENV === 'test' && global.__TEST_MODELS__) {
|
||||
console.log(`🔧 DEBUG: Using global test models from models/index.js`);
|
||||
return global.__TEST_MODELS__;
|
||||
}
|
||||
|
||||
// If no global models, use the default cached models
|
||||
if (!module.exports._defaultModels) {
|
||||
console.log(`🔧 DEBUG: Creating new models instance in models/index.js`);
|
||||
module.exports._defaultModels = createDefaultModels();
|
||||
}
|
||||
return module.exports._defaultModels;
|
||||
}
|
||||
|
||||
function createDefaultModels() {
|
||||
// Check if models are already initialized (for tests)
|
||||
if (process.env.NODE_ENV === 'test' && global.__TEST_MODELS__) {
|
||||
console.log(`🔧 DEBUG: Using global test models from models/index.js`);
|
||||
module.exports = global.__TEST_MODELS__;
|
||||
} else {
|
||||
console.log(`🔧 DEBUG: Creating new models instance in models/index.js`);
|
||||
// Configure database based on environment
|
||||
let sequelize;
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
@@ -30,6 +20,9 @@ function createDefaultModels() {
|
||||
storage: ':memory:',
|
||||
logging: false
|
||||
});
|
||||
} else {
|
||||
logging: false
|
||||
});
|
||||
} else {
|
||||
// Use PostgreSQL for production/development
|
||||
sequelize = new Sequelize(
|
||||
|
||||
Reference in New Issue
Block a user