Class: MiddlewareService
Orchestrates dynamic middleware registered through the Medusa Middleware API
Constructors
constructor
• new MiddlewareService(container
)
Parameters
Name | Type |
---|---|
container | any |
Defined in
Properties
postAuthentication_
• postAuthentication_: any
[]
Defined in
preAuthentication_
• preAuthentication_: any
[]
Defined in
preCartCreation_
• preCartCreation_: any
[]
Defined in
routers
• routers: Object
Defined in
Methods
addPostAuthentication
▸ addPostAuthentication(middleware
, options
): void
Adds a middleware function to be called after authentication is completed.
Parameters
Name | Type | Description |
---|---|---|
middleware | Function | the middleware function. Should return a middleware function. |
options | any | the arguments that will be passed to the middleware |
Returns
void
Defined in
addPreAuthentication
▸ addPreAuthentication(middleware
, options
): void
Adds a middleware function to be called before authentication is completed.
Parameters
Name | Type | Description |
---|---|---|
middleware | Function | the middleware function. Should return a middleware function. |
options | any | the arguments that will be passed to the middleware |
Returns
void
Defined in
addPreCartCreation
▸ addPreCartCreation(middleware
): void
Adds a middleware function to be called before cart creation
Parameters
Name | Type | Description |
---|---|---|
middleware | Function | the middleware function. Should return a middleware function. |
Returns
void
Defined in
addRouter
▸ addRouter(path
, router
): void
Parameters
Name | Type |
---|---|
path | any |
router | any |
Returns
void
Defined in
getRouters
▸ getRouters(path
): any
Parameters
Name | Type |
---|---|
path | any |
Returns
any
Defined in
usePostAuthentication
▸ usePostAuthentication(app
): void
Adds post authentication middleware to an express app.
Parameters
Name | Type | Description |
---|---|---|
app | ExpressApp | the express app to add the middleware to |
Returns
void
Defined in
usePreAuthentication
▸ usePreAuthentication(app
): void
Adds pre authentication middleware to an express app.
Parameters
Name | Type | Description |
---|---|---|
app | ExpressApp | the express app to add the middleware to |
Returns
void
Defined in
usePreCartCreation
▸ usePreCartCreation(): any
[]
Returns
any
[]
Defined in
validateMiddleware_
▸ validateMiddleware_(fn
): void
Validates a middleware function, throws if fn is not of type function.
Parameters
Name | Type | Description |
---|---|---|
fn | Function | the middleware function to validate. |
Returns
void