반응형
node에서 admin-bro를 세팅하고 서버를 실행했더니
express-session deprecated undefined resave option; provide resave option node_modules/@admin-bro/express/lib/buildAuthenticatedRouter.js:56:41
express-session deprecated undefined saveUninitialized option; provide saveUninitialized option node_modules/@admin-bro/express/lib/buildAuthenticatedRouter.js:56:41
뭔가가 deprecated 되었다는 메시지가 계속 뜬다
위 글 기준 index.js 코드에서 수정할 부분을 보자
① index.js
const express = require("express");
const app = express();
const path = require("path");
const cors = require('cors')
const AdminBro = require('admin-bro')
const AdminBroExpress = require('@admin-bro/express')
const AdminBroMongoose = require('@admin-bro/mongoose')
const User = require('./models/User')
const config = require("./config/key"); // mongoDB 설정 파일
const mongoose = require("mongoose");
const connect = mongoose.connect(config.mongoURI,
{
useNewUrlParser: true, useUnifiedTopology: true,
useCreateIndex: true, useFindAndModify: false
})
.then(() => console.log('MongoDB Connected...'))
.catch(err => console.log(err));
AdminBro.registerAdapter(AdminBroMongoose)
const adminBro = new AdminBro({
databases: [ mongoose ]
})
const ADMIN = {
email: 'admin@a.aa',
password: '12341234'
};
const router = AdminBroExpress.buildAuthenticatedRouter(adminBro, {
cookieName: 'adminBro',
cookiePassword: 'testtest',
authenticate: async (email, password) => {
if (ADMIN.password === password && ADMIN.email === email) {
return ADMIN
}
return null
},
}, null, { // 추가
resave: false, // 추가
saveUninitialized: true, // 추가
});
app.use(adminBro.options.rootPath, router)
const port = process.env.PORT || 5000
app.listen(port, () => {
console.log(`Server Listening on ${port}`)
});
이렇게 수정해 주면 계속 뜨던 메시지가 사라진다
반응형