Session improvements - #98
Open
LarsVomMars wants to merge 9 commits into
Open
Conversation
Contributor
Author
|
Thanks @marvinborner for the tests :) |
LarsVomMars
marked this pull request as ready for review
August 5, 2020 22:54
Contributor
Author
|
I think we should discuss the last two points on the list because so far I see this, there is not really a better solution to them. |
zhmushan
reviewed
Aug 6, 2020
zhmushan
reviewed
Aug 6, 2020
zhmushan
reviewed
Aug 6, 2020
Owner
|
Below is my design: // session.ts
export const key = Symbol("abc.session")
interface SessionConfig {
skipper: ...
// required
store: ...
}
// this func create a session mw
export function mw(cfg) {}
export function get(name: string, c: Context): Session {
// const s = c.get(key)
// return s.get(name)
}
// main.ts
import * as session from "./session.ts"
app.use(session.mw({...}))
app.get("/", c => {
sess = session.get("session", c)
// Then, we need a way to set the session options, such as maxAge, etc.
}) |
Contributor
Author
|
Although I don't see how this would improve the workflow yet is justifiable for the user in any way. -- |
Owner
|
@LarsVomMars Sorry for late, thanks for your contribution. |
Contributor
Author
|
You free to edit. I can't do this much atm, because my attention is currently drawn to some other projects. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Better typings
I already considered this but IMO it's very useful to be able to store data of any kind/type in a session variable without being limited to some basic types.
You probably could serialize the data into JSON on the store side which would get rid of 3
anytypings.Session field
Well I first thought of using a
CustomContextfor that but this would only complicate things because the user would have to instantiate the CC on every request he wants to access the session data.~ Lars