---
lang: en
title: 'API docs: express.middlewaremixin'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/express
permalink: /doc/en/lb4/apidocs.express.middlewaremixin.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/express](./express.md) &gt; [MiddlewareMixin](./express.middlewaremixin.md)

## MiddlewareMixin() function

<b>Signature:</b>

```typescript
export declare function MiddlewareMixin<T extends MixinTarget<Context>>(superClass: T): {
    new (...args: any[]): {
        expressMiddleware(key: BindingAddress, middleware: ExpressRequestHandler | ExpressRequestHandler[], options?: MiddlewareBindingOptions | undefined): Binding<Middleware>;
        expressMiddleware<CFG>(middlewareFactory: ExpressMiddlewareFactory<CFG>, middlewareConfig?: CFG | undefined, options?: MiddlewareBindingOptions | undefined): Binding<Middleware>;
        expressMiddleware<CFG_1>(factoryOrKey: BindingAddress<Middleware> | ExpressMiddlewareFactory<CFG_1>, configOrHandler: ExpressRequestHandler | ExpressRequestHandler[] | CFG_1, options?: MiddlewareBindingOptions | undefined): Binding<Middleware>;
        middleware(middleware: Middleware | Constructor<Provider<Middleware>>, options?: MiddlewareBindingOptions): Binding<Middleware>;
        readonly name: string;
        readonly subscriptionManager: loopbackContext.ContextSubscriptionManager;
        scope: loopbackContext.BindingScope;
        readonly parent: Context | undefined;
        emitEvent: <T_1 extends loopbackContext.ContextEvent>(type: string, event: T_1) => void;
        emitError: (err: unknown) => void;
        bind: <ValueType = any>(key: BindingAddress<ValueType>) => Binding<ValueType>;
        add: (binding: Binding<unknown>) => Context;
        configure: <ConfigValueType = any>(key?: BindingAddress<unknown> | undefined) => Binding<ConfigValueType>;
        getConfigAsValueOrPromise: <ConfigValueType_1>(key: BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: loopbackContext.ResolutionOptions | undefined) => loopbackContext.ValueOrPromise<ConfigValueType_1 | undefined>;
        getConfig: <ConfigValueType_2>(key: BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: loopbackContext.ResolutionOptions | undefined) => Promise<ConfigValueType_2 | undefined>;
        getConfigSync: <ConfigValueType_3>(key: BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: loopbackContext.ResolutionOptions | undefined) => ConfigValueType_3 | undefined;
        unbind: (key: BindingAddress<unknown>) => boolean;
        subscribe: (observer: loopbackContext.ContextEventObserver) => loopbackContext.Subscription;
        unsubscribe: (observer: loopbackContext.ContextEventObserver) => boolean;
        close: () => void;
        isSubscribed: (observer: loopbackContext.ContextObserver) => boolean;
        createView: <T_2 = unknown>(filter: loopbackContext.BindingFilter, comparator?: loopbackContext.BindingComparator | undefined, options?: Omit<loopbackContext.ResolutionOptions, "session"> | undefined) => loopbackContext.ContextView<T_2>;
        contains: (key: BindingAddress<unknown>) => boolean;
        isBound: (key: BindingAddress<unknown>) => boolean;
        getOwnerContext: (keyOrBinding: BindingAddress<unknown> | Readonly<Binding<unknown>>) => Context | undefined;
        getScopedContext: (scope: loopbackContext.BindingScope.APPLICATION | loopbackContext.BindingScope.SERVER | loopbackContext.BindingScope.REQUEST) => Context | undefined;
        getResolutionContext: (binding: Readonly<Binding<unknown>>) => Context | undefined;
        isVisibleTo: (ctx: Context) => boolean;
        find: <ValueType_1 = any>(pattern?: string | RegExp | loopbackContext.BindingFilter | undefined) => Readonly<Binding<ValueType_1>>[];
        findByTag: <ValueType_2 = any>(tagFilter: RegExp | loopbackContext.BindingTag) => Readonly<Binding<ValueType_2>>[];
        get: {
            <ValueType_3>(keyWithPath: BindingAddress<ValueType_3>, session?: loopbackContext.ResolutionSession | undefined): Promise<ValueType_3>;
            <ValueType_4>(keyWithPath: BindingAddress<ValueType_4>, options: loopbackContext.ResolutionOptions): Promise<ValueType_4 | undefined>;
        };
        getSync: {
            <ValueType_5>(keyWithPath: BindingAddress<ValueType_5>, session?: loopbackContext.ResolutionSession | undefined): ValueType_5;
            <ValueType_6>(keyWithPath: BindingAddress<ValueType_6>, options?: loopbackContext.ResolutionOptions | undefined): ValueType_6 | undefined;
        };
        getBinding: {
            <ValueType_7 = any>(key: BindingAddress<ValueType_7>): Binding<ValueType_7>;
            <ValueType_8>(key: BindingAddress<ValueType_8>, options?: {
                optional?: boolean | undefined;
            } | undefined): Binding<ValueType_8> | undefined;
        };
        findOrCreateBinding: <T_3>(key: BindingAddress<T_3>, policy?: loopbackContext.BindingCreationPolicy | undefined) => Binding<T_3>;
        getValueOrPromise: <ValueType_9>(keyWithPath: BindingAddress<ValueType_9>, optionsOrSession?: loopbackContext.ResolutionOptionsOrSession | undefined) => loopbackContext.ValueOrPromise<ValueType_9 | undefined>;
        toJSON: () => loopbackContext.JSONObject;
        inspect: (options?: loopbackContext.ContextInspectOptions | undefined) => loopbackContext.JSONObject;
        on: {
            (eventName: "bind" | "unbind", listener: loopbackContext.ContextEventListener): Context;
            (event: string | symbol, listener: (...args: any[]) => void): Context;
        };
        once: {
            (eventName: "bind" | "unbind", listener: loopbackContext.ContextEventListener): Context;
            (event: string | symbol, listener: (...args: any[]) => void): Context;
        };
        addListener: (event: string | symbol, listener: (...args: any[]) => void) => Context;
        removeListener: (event: string | symbol, listener: (...args: any[]) => void) => Context;
        off: (event: string | symbol, listener: (...args: any[]) => void) => Context;
        removeAllListeners: (event?: string | symbol | undefined) => Context;
        setMaxListeners: (n: number) => Context;
        getMaxListeners: () => number;
        listeners: (event: string | symbol) => Function[];
        rawListeners: (event: string | symbol) => Function[];
        emit: (event: string | symbol, ...args: any[]) => boolean;
        listenerCount: (type: string | symbol) => number;
        prependListener: (event: string | symbol, listener: (...args: any[]) => void) => Context;
        prependOnceListener: (event: string | symbol, listener: (...args: any[]) => void) => Context;
        eventNames: () => (string | symbol)[];
    };
} & T;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  superClass | T |  |

<b>Returns:</b>

{ new (...args: any\[\]): { expressMiddleware(key: [BindingAddress](./context.bindingaddress.md)<!-- -->, middleware: [ExpressRequestHandler](./express.expressrequesthandler.md) \| [ExpressRequestHandler](./express.expressrequesthandler.md)<!-- -->\[\], options?: [MiddlewareBindingOptions](./express.middlewarebindingoptions.md) \| undefined): [Binding](./context.binding.md)<!-- -->&lt;[Middleware](./express.middleware.md)<!-- -->&gt;; expressMiddleware&lt;CFG&gt;(middlewareFactory: [ExpressMiddlewareFactory](./express.expressmiddlewarefactory.md)<!-- -->&lt;CFG&gt;, middlewareConfig?: CFG \| undefined, options?: [MiddlewareBindingOptions](./express.middlewarebindingoptions.md) \| undefined): [Binding](./context.binding.md)<!-- -->&lt;[Middleware](./express.middleware.md)<!-- -->&gt;; expressMiddleware&lt;CFG\_1&gt;(factoryOrKey: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;[Middleware](./express.middleware.md)<!-- -->&gt; \| [ExpressMiddlewareFactory](./express.expressmiddlewarefactory.md)<!-- -->&lt;CFG\_1&gt;, configOrHandler: [ExpressRequestHandler](./express.expressrequesthandler.md) \| [ExpressRequestHandler](./express.expressrequesthandler.md)<!-- -->\[\] \| CFG\_1, options?: [MiddlewareBindingOptions](./express.middlewarebindingoptions.md) \| undefined): [Binding](./context.binding.md)<!-- -->&lt;[Middleware](./express.middleware.md)<!-- -->&gt;; middleware(middleware: [Middleware](./express.middleware.md) \| [Constructor](./context.constructor.md)<!-- -->&lt;[Provider](./context.provider.md)<!-- -->&lt;[Middleware](./express.middleware.md)<!-- -->&gt;&gt;, options?: [MiddlewareBindingOptions](./express.middlewarebindingoptions.md)<!-- -->): [Binding](./context.binding.md)<!-- -->&lt;[Middleware](./express.middleware.md)<!-- -->&gt;; readonly name: string; readonly subscriptionManager: loopbackContext.[ContextSubscriptionManager](./context.contextsubscriptionmanager.md)<!-- -->; scope: loopbackContext.[BindingScope](./context.bindingscope.md)<!-- -->; readonly parent: [Context](./context.context.md) \| undefined; emitEvent: &lt;T\_1 extends loopbackContext.[ContextEvent](./context.contextevent.md)<!-- -->&gt;(type: string, event: T\_1) =&gt; void; emitError: (err: unknown) =&gt; void; bind: &lt;ValueType = any&gt;(key: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;ValueType&gt;) =&gt; [Binding](./context.binding.md)<!-- -->&lt;ValueType&gt;; add: (binding: [Binding](./context.binding.md)<!-- -->&lt;unknown&gt;) =&gt; [Context](./context.context.md)<!-- -->; configure: &lt;ConfigValueType = any&gt;(key?: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;unknown&gt; \| undefined) =&gt; [Binding](./context.binding.md)<!-- -->&lt;ConfigValueType&gt;; getConfigAsValueOrPromise: &lt;ConfigValueType\_1&gt;(key: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;unknown&gt;, propertyPath?: string \| undefined, resolutionOptions?: loopbackContext.[ResolutionOptions](./context.resolutionoptions.md) \| undefined) =&gt; loopbackContext.[ValueOrPromise](./context.valueorpromise.md)<!-- -->&lt;ConfigValueType\_1 \| undefined&gt;; getConfig: &lt;ConfigValueType\_2&gt;(key: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;unknown&gt;, propertyPath?: string \| undefined, resolutionOptions?: loopbackContext.[ResolutionOptions](./context.resolutionoptions.md) \| undefined) =&gt; Promise&lt;ConfigValueType\_2 \| undefined&gt;; getConfigSync: &lt;ConfigValueType\_3&gt;(key: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;unknown&gt;, propertyPath?: string \| undefined, resolutionOptions?: loopbackContext.[ResolutionOptions](./context.resolutionoptions.md) \| undefined) =&gt; ConfigValueType\_3 \| undefined; unbind: (key: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;unknown&gt;) =&gt; boolean; subscribe: (observer: loopbackContext.[ContextEventObserver](./context.contexteventobserver.md)<!-- -->) =&gt; loopbackContext.[Subscription](./context.subscription.md)<!-- -->; unsubscribe: (observer: loopbackContext.[ContextEventObserver](./context.contexteventobserver.md)<!-- -->) =&gt; boolean; close: () =&gt; void; isSubscribed: (observer: loopbackContext.[ContextObserver](./context.contextobserver.md)<!-- -->) =&gt; boolean; createView: &lt;T\_2 = unknown&gt;(filter: loopbackContext.[BindingFilter](./context.bindingfilter.md)<!-- -->, comparator?: loopbackContext.[BindingComparator](./context.bindingcomparator.md) \| undefined, options?: Omit&lt;loopbackContext.[ResolutionOptions](./context.resolutionoptions.md)<!-- -->, "session"&gt; \| undefined) =&gt; loopbackContext.[ContextView](./context.contextview.md)<!-- -->&lt;T\_2&gt;; contains: (key: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;unknown&gt;) =&gt; boolean; isBound: (key: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;unknown&gt;) =&gt; boolean; getOwnerContext: (keyOrBinding: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;unknown&gt; \| Readonly&lt;[Binding](./context.binding.md)<!-- -->&lt;unknown&gt;&gt;) =&gt; [Context](./context.context.md) \| undefined; getScopedContext: (scope: loopbackContext.[BindingScope.APPLICATION](./context.bindingscope.md) \| loopbackContext.[BindingScope.SERVER](./context.bindingscope.md) \| loopbackContext.[BindingScope.REQUEST](./context.bindingscope.md)<!-- -->) =&gt; [Context](./context.context.md) \| undefined; getResolutionContext: (binding: Readonly&lt;[Binding](./context.binding.md)<!-- -->&lt;unknown&gt;&gt;) =&gt; [Context](./context.context.md) \| undefined; isVisibleTo: (ctx: [Context](./context.context.md)<!-- -->) =&gt; boolean; find: &lt;ValueType\_1 = any&gt;(pattern?: string \| RegExp \| loopbackContext.[BindingFilter](./context.bindingfilter.md) \| undefined) =&gt; Readonly&lt;[Binding](./context.binding.md)<!-- -->&lt;ValueType\_1&gt;&gt;\[\]; findByTag: &lt;ValueType\_2 = any&gt;(tagFilter: RegExp \| loopbackContext.[BindingTag](./context.bindingtag.md)<!-- -->) =&gt; Readonly&lt;[Binding](./context.binding.md)<!-- -->&lt;ValueType\_2&gt;&gt;\[\]; get: { &lt;ValueType\_3&gt;(keyWithPath: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;ValueType\_3&gt;, session?: loopbackContext.[ResolutionSession](./context.resolutionsession.md) \| undefined): Promise&lt;ValueType\_3&gt;; &lt;ValueType\_4&gt;(keyWithPath: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;ValueType\_4&gt;, options: loopbackContext.[ResolutionOptions](./context.resolutionoptions.md)<!-- -->): Promise&lt;ValueType\_4 \| undefined&gt;; }; getSync: { &lt;ValueType\_5&gt;(keyWithPath: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;ValueType\_5&gt;, session?: loopbackContext.[ResolutionSession](./context.resolutionsession.md) \| undefined): ValueType\_5; &lt;ValueType\_6&gt;(keyWithPath: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;ValueType\_6&gt;, options?: loopbackContext.[ResolutionOptions](./context.resolutionoptions.md) \| undefined): ValueType\_6 \| undefined; }; getBinding: { &lt;ValueType\_7 = any&gt;(key: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;ValueType\_7&gt;): [Binding](./context.binding.md)<!-- -->&lt;ValueType\_7&gt;; &lt;ValueType\_8&gt;(key: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;ValueType\_8&gt;, options?: { optional?: boolean \| undefined; } \| undefined): [Binding](./context.binding.md)<!-- -->&lt;ValueType\_8&gt; \| undefined; }; findOrCreateBinding: &lt;T\_3&gt;(key: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;T\_3&gt;, policy?: loopbackContext.[BindingCreationPolicy](./context.bindingcreationpolicy.md) \| undefined) =&gt; [Binding](./context.binding.md)<!-- -->&lt;T\_3&gt;; getValueOrPromise: &lt;ValueType\_9&gt;(keyWithPath: [BindingAddress](./context.bindingaddress.md)<!-- -->&lt;ValueType\_9&gt;, optionsOrSession?: loopbackContext.[ResolutionOptionsOrSession](./context.resolutionoptionsorsession.md) \| undefined) =&gt; loopbackContext.[ValueOrPromise](./context.valueorpromise.md)<!-- -->&lt;ValueType\_9 \| undefined&gt;; toJSON: () =&gt; loopbackContext.[JSONObject](./context.jsonobject.md)<!-- -->; inspect: (options?: loopbackContext.[ContextInspectOptions](./context.contextinspectoptions.md) \| undefined) =&gt; loopbackContext.[JSONObject](./context.jsonobject.md)<!-- -->; on: { (eventName: "bind" \| "unbind", listener: loopbackContext.[ContextEventListener](./context.contexteventlistener.md)<!-- -->): [Context](./context.context.md)<!-- -->; (event: string \| symbol, listener: (...args: any\[\]) =&gt; void): [Context](./context.context.md)<!-- -->; }; once: { (eventName: "bind" \| "unbind", listener: loopbackContext.[ContextEventListener](./context.contexteventlistener.md)<!-- -->): [Context](./context.context.md)<!-- -->; (event: string \| symbol, listener: (...args: any\[\]) =&gt; void): [Context](./context.context.md)<!-- -->; }; addListener: (event: string \| symbol, listener: (...args: any\[\]) =&gt; void) =&gt; [Context](./context.context.md)<!-- -->; removeListener: (event: string \| symbol, listener: (...args: any\[\]) =&gt; void) =&gt; [Context](./context.context.md)<!-- -->; off: (event: string \| symbol, listener: (...args: any\[\]) =&gt; void) =&gt; [Context](./context.context.md)<!-- -->; removeAllListeners: (event?: string \| symbol \| undefined) =&gt; [Context](./context.context.md)<!-- -->; setMaxListeners: (n: number) =&gt; [Context](./context.context.md)<!-- -->; getMaxListeners: () =&gt; number; listeners: (event: string \| symbol) =&gt; Function\[\]; rawListeners: (event: string \| symbol) =&gt; Function\[\]; emit: (event: string \| symbol, ...args: any\[\]) =&gt; boolean; listenerCount: (type: string \| symbol) =&gt; number; prependListener: (event: string \| symbol, listener: (...args: any\[\]) =&gt; void) =&gt; [Context](./context.context.md)<!-- -->; prependOnceListener: (event: string \| symbol, listener: (...args: any\[\]) =&gt; void) =&gt; [Context](./context.context.md)<!-- -->; eventNames: () =&gt; (string \| symbol)\[\]; }; } &amp; T


