From 95bcaf3c5e1b74b369d92aae386f9de2935c5685 Mon Sep 17 00:00:00 2001 From: Primakov Alexandr Alexandrovich Date: Thu, 8 May 2025 15:48:02 +0300 Subject: [PATCH] 2 --- server/utils/const.ts | 4 ---- server/utils/mongo.ts | 13 ++++++++----- server/utils/mongoose.ts | 5 +++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/server/utils/const.ts b/server/utils/const.ts index 07c5175..5d19080 100644 --- a/server/utils/const.ts +++ b/server/utils/const.ts @@ -2,7 +2,3 @@ import 'dotenv/config'; // Connection URL export const mongoUrl = process.env.MONGO_ADDR - -console.log('=======================================================') -console.log('mongoUrl', mongoUrl) -console.log('=======================================================') diff --git a/server/utils/mongo.ts b/server/utils/mongo.ts index 821b9c4..e98dfac 100644 --- a/server/utils/mongo.ts +++ b/server/utils/mongo.ts @@ -1,15 +1,18 @@ -const MDBClient = require('mongodb').MongoClient +import { MongoClient as MDBClient } from 'mongodb' -const { mongoUrl } = require('./const') +import { mongoUrl } from './const' const dbInstanses = { } +console.log('=======================================================') +console.log('mongoUrl', mongoUrl) +console.log('=======================================================') + + const mongoDBConnect = async () => { try { - const MongoClient = new MDBClient(mongoUrl, { - useUnifiedTopology: true, - }) + const MongoClient = new MDBClient(mongoUrl, {}) const client = await MongoClient.connect() console.log('Подключение к MongoDB успешно') return client diff --git a/server/utils/mongoose.ts b/server/utils/mongoose.ts index d018e66..257b430 100644 --- a/server/utils/mongoose.ts +++ b/server/utils/mongoose.ts @@ -2,6 +2,11 @@ import mongoose from 'mongoose' import { mongoUrl } from './const' +console.log('=======================================================') +console.log('mongoUrl2', mongoUrl) +console.log('=======================================================') + + mongoose.connect(`${mongoUrl}`).then(() => { console.log('Подключение к MongoDB успешно') }).catch((err) => {