Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for sessionStore config in the docs for Keystone 5 is outdated #147

Open
leopoldkristjansson opened this issue May 13, 2021 · 0 comments

Comments

@leopoldkristjansson
Copy link

leopoldkristjansson commented May 13, 2021

Bug report

Describe the bug

The following code example seems outdated:

const expressSession = require('express-session');
const MongoStore = require('connect-mongo')(expressSession);

const keystone = new Keystone({
  sessionStore: new MongoStore({ url: 'mongodb://localhost/my-app' }),
});

from:

https://www.keystonejs.com/keystonejs/keystone/#sessionstore

It returns an error

✔ Keystone server listening on port 3000
✖ Initialising Keystone instance
TypeError: Class constructor MongoStore cannot be invoked without 'new'
    at Object.<anonymous> (/folder/project-using-keystone/index.js:18:44)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at executeDefaultServer (/folder/project-using-keystone/node_modules/@keystonejs/keystone/bin/utils.js:140:7)
error Command failed with exit code 1.

Additional context

It looks to me like the following code is the way to go, but it does not use express-session at all.

const MongoStore = require('connect-mongo');

const keystone = new Keystone({
  sessionStore: MongoStore.create({ mongoUrl: process.env.MONGO_URI }),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants