Buenas tardes comunidad , he intentado utilizar el MongoStore pero me esta arrojando este error :
Assertion failed: You must provide either mongoUrl|clientPromise|client in options
/home/oliver/Escritorio/NodeJS-ExpressJS-MongoDB/node_modules/connect-mongo/build/main/lib/MongoStore.js:119 throw new Error('Cannot init client. Please provide correct options'); ^
Error: Cannot init client. Please provide correct options at new MongoStore (/home/oliver/Escritorio/NodeJS-ExpressJS-MongoDB/node_modules/connect-mongo/build/main/lib/MongoStore.js:119:19) at Function.create (/home/oliver/Escritorio/NodeJS-ExpressJS-MongoDB/node_modules/connect-mongo/build/main/lib/MongoStore.js:136:16) at file:///home/oliver/Escritorio/NodeJS-ExpressJS-MongoDB/server.js:12:23 at ModuleJob.run (internal/modules/esm/module_job.js:152:23) at async Loader.import (internal/modules/esm/loader.js:166:24) at async Object.loadESM (internal/process/esm_loader.js:68:5) [nodemon] app crashed - waiting for file changes before starting...
y este es mi codigo:
import express from 'express';
import session from 'express-session';
import MongoStore from 'connect-mongo';
const MONGO_URL = 'mongodb://127.0.0.1:27017/auth'
const app = express();
app.use(session({
secret:'ESTO ES SECRETO',
resave: true,
saveUninitialized: true,
store: MongoStore.create({
mongourl:MONGO_URL,
autoReconnect: true
})
}))
app.get('/', (req, res) =>{
req.session.cuenta = req.session.cuenta ? req.session.cuenta + 1 : 1;
res.send(`Hola! Has visto esta pagina : ${req.session.cuenta}`);
})
app.listen(3000,() =>{
console.log('listening on port 3000');
})
NOTA: ya intente declarando import connectMongo from 'connect-mongo', const MongoStore = connectMongo(session); y tampoco funciono.