Replies: 3 comments 5 replies
-
Yes, I created PR #23, it basically is what you said. One Another Change is the |
Beta Was this translation helpful? Give feedback.
-
From your use case, I think of another situation where this "static property" approach don't work well, that is if someone want to use different store / cookie options for different middleware. Maybe it's better to ditch the static properties. Pass in the store / cookie options in From the api change perspective, It's from const store = new SomeStore();
const store2 = new OtherStore();
const session = new Session(store, options);
const session2 = new Session(store2, options2);
app.use(session.initMiddleware());
// some specific route:
router.use(session.initMiddleware()); to const store = new SomeStore();
const store2 = new OtherStore();
app.use(Session.initMiddleware(store, options));
// some specific route:
router.use(Session.initMiddleware(store2, options2)); And it works with your use case too. User can create a store in |
Beta Was this translation helpful? Give feedback.
-
That way we can also ditch the weird (at least for me) static property stuff. All the store, session options are only used to create a middleware in |
Beta Was this translation helpful? Give feedback.
-
Right now, a single instance of the Session class is used globally per session. In my testing, this hasn't been an issue, but it should probably be addressed to prevent even the possibility of issues.
I want to avoid breaking changes to end-user code if possible. If it's not possible, we'll make it a new major version indicating breaking changes.
I have an idea of how to fix this using JavaScript
Map
data structure to put each session in a temporary store just for the lifecycle of the request. Then, instead of usingctx.state.session.get()
to pull the request's session from the global instance, it will pull it from aMap
entry. If implemented properly, it should avoid breaking user code but make the library more robust and secure.Beta Was this translation helpful? Give feedback.
All reactions