-
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
[SPIKE] DO NOT MERGE feat: try mw with passport login example #5302
Conversation
|
||
@intercept('PassportInitMW') | ||
@intercept('PassportSessionMW') | ||
@intercept('FacebookOauth2MW') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be simplified as @intercept('PassportInitMW', 'PassportSessionMW', 'FacebookOauth2MW')
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
@@ -91,3 +97,34 @@ export const mapProfile = function (user: User): UserProfile { | |||
}; | |||
return userProfile; | |||
}; | |||
|
|||
export class PassportInitMW implements Provider<Interceptor> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to wrap a simple Express middleware as provider class for local interceptors. You simply bind it to the context, or create a binding for it:
app.bind('PassportInitMW').to(toInterceptor(passport.initialize());
// or
const binding = new Binding('PassportInitMW').to(toInterceptor(passport.initialize());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
…ware - add `Middleware` as interceptors that use request context - add `InvokeMiddleware` to invoke middleware in a chain - add extension points for Middleware extensions - add helper methods to adapt express middleware as interceptors - add helper methods to adapt LoopBack middleware chain as Express middleware - add ExpressServer and ExpressApplication to extend Express with LoopBack core
- add `InvokeMiddleware` action to the default sequence - add `middleware/expressMiddleware` APIs to RestServer/RestApplication - use middleware APIs to register CORS and OpenAPI spec endpoints BREAKING CHANGE: `basePath` now also applies to endpoints that serve OpenAPI specs. For example, the OpenAPI specs are available at `/api/openapi.json` or `/api/openapi.yaml` if the base path is set to `/api`.
c97955f
to
2539258
Compare
59d2891
to
16bce44
Compare
constructor( | ||
) {} | ||
|
||
@intercept('passport-init-mw', 'passport-session-mw', 'passport-facebook') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible to define a custom decorator such as:
export function facebookLogin() {
return intercept('passport-init-mw', 'passport-session-mw', 'passport-facebook');
}
Then we can use @facebookLogin()
.
Nice and clean. 👍 |
abc2ee8
to
7970266
Compare
bda5b70
to
3931b3b
Compare
example for #5118
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated👉 Check out how to submit a PR 👈