title: Loopback 4 extensions: how to use them with middleware sequence
body: <p>I would like to use packages like the following one with Loopback 4.:</p>
  <p><a href="https://github.com/sourcefuse/loopback4-helmet#readme" rel="nofollow noreferrer">https://github.com/sourcefuse/loopback4-helmet#readme</a></p>
  <p>There are several similar packages, they all have the same problem:</p>
  <p>They still use the Action based sequence syntax, but Loopback comes with a Middleware based sequence now and the other syntax is deprecated.</p>
  <p>I know I can add custom middleware to the sequence. But I don't see how should I use these Action based examples with the new syntax?</p>
  <p>I mean, in Looback 4 middleware functions there is no dependency injection. However the helmet package makes use of that using the old syntax:</p>
  <pre><code>export class MySequence implements SequenceHandler {
    constructor(
      @inject(SequenceActions.FIND_ROUTE) protected findRoute: FindRoute,
      @inject(SequenceActions.PARSE_PARAMS) protected parseParams: ParseParams,
      @inject(SequenceActions.INVOKE_METHOD) protected invoke: InvokeMethod,
      @inject(SequenceActions.SEND) public send: Send,
      @inject(SequenceActions.REJECT) public reject: Reject,
      @inject(HelmetSecurityBindings.HELMET_SECURITY_ACTION)
      protected helmetAction: HelmetAction,
    ) {}
  
    async handle(context: RequestContext) {
      const requestTime = Date.now();
      try {
        const {request, response} = context;
        const route = this.findRoute(request);
        const args = await this.parseParams(request, route);
  
        // Helmet Action here
        await this.helmetAction(request, response);
  
        const result = await this.invoke(route, args);
        this.send(response, result);
      } catch (err) {
        ...
      } finally {
        ...
      }
    }
  }
  </code></pre>
  <p>So how do I wrap this.helmetAction(...) in a custom middleware, so I can add it to the sequence. I cannot inject like this in middleware, can I?</p>
  <pre><code>@inject(HelmetSecurityBindings.HELMET_SECURITY_ACTION)
  protected helmetAction: HelmetAction,
  </code></pre>
  <p>The whole documentation on Middleware and Middleware sequence is confusing like hell, at least for me.</p>
  <p>Any help please?</p>