-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
A sequence action for stateful requests (HTTP sessions) #1863
Comments
@GuerricPhalippou thank you for opening the issue. For reference, here is our original discussion on StackOverflow: https://stackoverflow.com/q/52833380/69868 As I wrote on StackOverflow, I think that ideally, session handling should be implemented as a new Sequence action - see Sequence docs. class MySequence {
// skipping constructor with dependencies to be injected
async handle(context: RequestContext) {
try {
// the following line is new
const session = this.restoreSession(context);
// the default sequence continues here
const route = this.findRoute(context.request);
const params = await this.parseParams(context.request, route);
const result = await this.invoke(route, params);
await this.send(context.response, result);
} catch (error) {
await this.reject(context, error);
}
}
} The sequence action
On of our design goals for LoopBack 4 was to make it easy for 3rd party developers to contribute extensions and thus keep the framework modular. IMO, session handling should live in a new module independent from I am expecting there will be many users looking for HTTP session support, therefore it makes sense to me to keep the session extension inside @GuerricPhalippou would you like to contribute this session extension yourself? I am happy to help you along the way. |
@bajtos I'm sorry but I dropped Loopback 4 and rollbacked to Loopback 3 since the features I need will not be implemented in a near future. Plus, my employer does not allocate time for open source contribution and I feel like it takes time to dive in Loopback 4 implementation and provide a solution that covers everyone's use cases. |
@GuerricPhalippou Thanks for letting us know about your situation. I wish you good luck in your projects and hope to see you here again in the future, when LB4 comes closer to LB3 in terms feature parity :) |
@bajtos I want to contribute to create the new action, but actually I need a quickly solution for create the session and retrieve the sessionID, Could you please help me with that? |
@GuerricPhalippou i resolved this in the interim by using Lerna to create another Loopback 4 app package that uses Express server plus Request to get the JSESSIONID from the cookie. I then store this on Redis for any subsequent requests. I will be happy to share the solution for anyone who is deep into Loopback 4 that it’s impossible to rollback |
I'm interested by a solution for this feature. |
Any news ? |
Any news on this subject ? |
Hi @L-Luciano, @malek0512, @lazaro9318 im working on an implementation for the session support. You could find an early working solution here loopback-session, would be nice know if you get it to run. Let me know if you need help. @bajtos I'd like to contribute this package to the main mono repository. Let me know what you think of it. >Also, it would be great if someone of could help me with testing. I'm not really good at it. Thank you! |
Please check out #5118 |
@raymondfeng thanks this look great! Will check it out later today. |
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
Is this had been solved yet ? I still didn't clear about solution how to using express-session with Loopback4 |
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
This is still an issue. Looking the way to use express-session |
What speaks against using express-session invoked with |
Feature proposal
Since middlewares are internally used and not exposed to developers, there is no possible way to implement stateful requests, as it was done with the
express-session
middleware before v4.Current Behavior
The v4 complying solution would be a sequence action, but it doesn't exist yet in
RestBindings.SequenceActions
.Expected Behavior
Have a sequence action that retrieves cookies information and make it available to the app via context and dependency injection
The text was updated successfully, but these errors were encountered: