SoftwareBrothers/adminjs-expressjs

Express issue + improvement

Closed this issue · 3 comments

I noticed some errors when I run that inside a NODE_ENV=production env.

express-session deprecated undefined resave option; provide resave option at node_modules/admin-bro-expressjs/plugin.js:131:14
express-session deprecated undefined saveUninitialized option; provide saveUninitialized option at node_modules/admin-bro-expressjs/plugin.js:131:14
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.

We should have a options to set express.js values directly.
Something like that in plugin.js :

const buildAuthenticatedRouter = (admin, auth, predefinedRouter, expressOptions = {}) => {
  if (!cookieParser || !session) {
    throw new Error(['In order to use authentication, you have to install',
      'cookie-parser and express-session packages'].join(' '))
  }
  const router = predefinedRouter || express.Router()
  router.use(cookieParser())
  router.use(session({
    secret: auth.cookiePassword,
    name: auth.cookieName || 'adminbro',
    ...expressOptions
  }))

makes sense - added to TODO

You can take example from this repo that have this feature: https://github.com/alexgilbertDG/admin-bro-expressjs . Its only some line in the plugin.js file. For some weird reason, the pull request don't work. Thanks!

it was released in version 0.3.0