Refactor file handling in BuyProduct and Request models; implement file schema for better structure. Update routes to handle file uploads and downloads with improved error handling and logging. Adjust MongoDB connection management across scripts and routes for consistency.
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
const mongoose = require('mongoose');
|
||||
const mongoose = require('../../../utils/mongoose');
|
||||
require('dotenv').config();
|
||||
|
||||
// Подключение моделей - прямые пути без path.join и __dirname
|
||||
// Подключение моделей
|
||||
const Activity = require('../models/Activity');
|
||||
const User = require('../models/User');
|
||||
const Company = require('../models/Company');
|
||||
|
||||
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/procurement-platform';
|
||||
|
||||
const activityTemplates = [
|
||||
{
|
||||
type: 'request_received',
|
||||
@@ -53,8 +51,14 @@ const activityTemplates = [
|
||||
|
||||
async function seedActivities() {
|
||||
try {
|
||||
console.log('🌱 Connecting to MongoDB...');
|
||||
await mongoose.connect(MONGODB_URI);
|
||||
// Подключение к MongoDB происходит через server/utils/mongoose.ts
|
||||
console.log('🌱 Checking MongoDB connection...');
|
||||
if (mongoose.connection.readyState !== 1) {
|
||||
console.log('⏳ Waiting for MongoDB connection...');
|
||||
await new Promise((resolve) => {
|
||||
mongoose.connection.once('connected', resolve);
|
||||
});
|
||||
}
|
||||
console.log('✅ Connected to MongoDB');
|
||||
|
||||
// Найти тестового пользователя
|
||||
|
||||
Reference in New Issue
Block a user