after installing winston-mongodb
I got the following warning :
(node:9316) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
this is my app.js :
require('express-async-errors');
const express = require('express'),
config = require('config'),
morgan = require('morgan'),
helmet = require('helmet'),
winston = require('winston'),
mongoose = require('mongoose');
require('winston-mongodb');
mongoose.connect("mongodb://localhost:27017/wsep",
{ useNewUrlParser: true, useFindAndModify: false, useCreateIndex: true, useUnifiedTopology: true })
.then(connect => { console.log("connected to mongo db...") })
.catch(error => { console.log("could not connect to mongo db ...") })
winston.add(new winston.transports.MongoDB({
db: 'mongodb://localhost:27017/wsep'
}));
the warning above will be disappeared , if I remove/comment the following snippet code:
winston.add(new winston.transports.MongoDB({
db: 'mongodb://localhost:27017/wsep'
}));
EDIT:
package.json
{
"name": "backend-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "nodemon app.js",
"start": "node app.js"
},
"engines": {
"node": "13.5.0"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt-nodejs": "0.0.3",
"compression": "^1.7.4",
"config": "^3.2.5",
"express": "^4.17.1",
"express-async-errors": "^3.1.1",
"helmet": "^3.21.2",
"joi": "^14.3.1",
"jsonwebtoken": "^8.5.1",
"jwt-token-encrypt": "^1.0.4",
"lodash": "^4.17.15",
"mongoose": "^5.8.9",
"multer": "^1.4.2",
"winston": "^3.2.1",
"winston-mongodb": "^5.0.1"
},
"devDependencies": {
"nodemon": "^2.0.2"
}
}
You can just add useUnifiedTopology: true
to the options block of winston-mongodb
like this:
winston.add(new winston.transports.MongoDB({
db: 'mongodb://localhost:27017/wsep',
options: {
useUnifiedTopology: true,
}
}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With