MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / constructor

Method constructor

packages/express/src/types.ts:54–76  ·  view source on GitHub ↗

* Constructor for `MiddlewareContext` * @param request - Express request object * @param response - Express response object * @param parent - Parent context * @param name - Name of the middleware context

(
    public readonly request: Request,
    public readonly response: Response,
    parent?: Context,
    name?: string,
  )

Source from the content-addressed store, hash-verified

52 * @param name - Name of the middleware context
53 */
54 constructor(
55 public readonly request: Request,
56 public readonly response: Response,
57 parent?: Context,
58 name?: string,
59 ) {
60 super(parent, name);
61 this.scope = BindingScope.REQUEST;
62
63 // Set the request context as a property of Express request object so that
64 // downstream Express native integration can access `RequestContext`
65 // eslint-disable-next-line @typescript-eslint/no-explicit-any
66 (request as any)[MIDDLEWARE_CONTEXT] = this;
67
68 this.setupBindings();
69 onFinished(this.response, () => {
70 this.responseFinished = true;
71 // Close the request context when the http response is finished so that
72 // it can be recycled by GC
73 this.emit('close');
74 this.close();
75 });
76 }
77
78 protected setupBindings() {
79 this.bind(MiddlewareBindings.CONTEXT).to(this).lock();

Callers

nothing calls this directly

Calls 2

setupBindingsMethod · 0.95
closeMethod · 0.45

Tested by

no test coverage detected