MiddlewareService
Orchestrates dynamic middleware registered through the Medusa Middleware API
Constructors
constructor
new MiddlewareService()
Defined in
medusa/src/services/middleware.ts:22
Properties
postAuthentication_
Protected
Readonly
postAuthentication_: middlewareType
[]
Defined in
medusa/src/services/middleware.ts:17
preAuthentication_
Protected
Readonly
preAuthentication_: middlewareType
[]
Defined in
medusa/src/services/middleware.ts:18
preCartCreation_
Protected
Readonly
preCartCreation_: RequestHandler
<ParamsDictionary
, any
, any
, ParsedQs
, Record<string
, any
>>[]
Defined in
medusa/src/services/middleware.ts:19
routers
Protected
Readonly
routers: Record<string
, Router
[]>
Defined in
medusa/src/services/middleware.ts:20
Methods
addPostAuthentication
addPostAuthentication(middleware
, options
): void
Adds a middleware function to be called after authentication is completed.
Parameters
Name | Description |
---|---|
middleware | middlewareHandlerType |
options | Record<string , unknown > |
Returns
void
-void
: (optional) void
Defined in
medusa/src/services/middleware.ts:60
addPreAuthentication
addPreAuthentication(middleware
, options
): void
Adds a middleware function to be called before authentication is completed.
Parameters
Name | Description |
---|---|
middleware | middlewareHandlerType |
options | Record<string , unknown > |
Returns
void
-void
: (optional) void
Defined in
medusa/src/services/middleware.ts:79
addPreCartCreation
addPreCartCreation(middleware
): void
Adds a middleware function to be called before cart creation
Parameters
Name | Description |
---|---|
middleware | RequestHandler <ParamsDictionary , any , any , ParsedQs , Record<string , any >> |
Returns
void
-void
: (optional)
Defined in
medusa/src/services/middleware.ts:96
addRouter
addRouter(path
, router
): void
Parameters
Name |
---|
path |
router |
Returns
void
-void
: (optional)
Defined in
medusa/src/services/middleware.ts:29
getRouters
getRouters(path
): Router
[]
Parameters
Name |
---|
path |
Returns
Router
[]
-Router[]
:
-Router
:
Defined in
medusa/src/services/middleware.ts:34
usePostAuthentication
usePostAuthentication(app
): void
Adds post authentication middleware to an express app.
Parameters
Name | Description |
---|---|
app | Router |
Returns
void
-void
: (optional)
Defined in
medusa/src/services/middleware.ts:106
usePreAuthentication
usePreAuthentication(app
): void
Adds pre authentication middleware to an express app.
Parameters
Name | Description |
---|---|
app | Router |
Returns
void
-void
: (optional)
Defined in
medusa/src/services/middleware.ts:117
usePreCartCreation
usePreCartCreation(): RequestHandler
<ParamsDictionary
, any
, any
, ParsedQs
, Record<string
, any
>>[]
Returns
RequestHandler
<ParamsDictionary
, any
, any
, ParsedQs
, Record<string
, any
>>[]
-RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any\>\>[]
:
-RequestHandler
:
-any
: (optional)
-any
: (optional)
-Record
:
Defined in
medusa/src/services/middleware.ts:123
validateMiddleware_
validateMiddleware_(fn
): void
Validates a middleware function, throws if fn is not of type function.
Parameters
Name | Description |
---|---|
fn | unknown |
Returns
void
-void
: (optional) nothing if the middleware is a function