MiddlewareService
Orchestrates dynamic middleware registered through the Medusa Middleware API
Constructors
constructor
**new MiddlewareService**()
Properties
preCartCreation_
RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>[]Requiredrouters
Record<string, Router[]>RequiredMethods
addPostAuthentication
**addPostAuthentication**(middleware, options): void
Adds a middleware function to be called after authentication is completed.
Parameters
options
Record<string, unknown>RequiredReturns
void
void
voidaddPreAuthentication
**addPreAuthentication**(middleware, options): void
Adds a middleware function to be called before authentication is completed.
Parameters
options
Record<string, unknown>RequiredReturns
void
void
voidaddPreCartCreation
**addPreCartCreation**(middleware): void
Adds a middleware function to be called before cart creation
Parameters
middleware
RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>RequiredReturns
void
void
voidaddRouter
**addRouter**(path, router): void
Parameters
path
stringRequiredrouter
RouterRequiredReturns
void
void
voidgetRouters
**getRouters**(path): Router[]
Parameters
path
stringRequiredReturns
Router[]
Router[]
Router[]RequiredusePostAuthentication
**usePostAuthentication**(app): void
Adds post authentication middleware to an express app.
Parameters
app
RouterRequiredReturns
void
void
voidusePreAuthentication
**usePreAuthentication**(app): void
Adds pre authentication middleware to an express app.
Parameters
app
RouterRequiredReturns
void
void
voidusePreCartCreation
**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<ParamsDictionary, any, any, ParsedQs, Record<string, any>>[]RequiredvalidateMiddleware_
**validateMiddleware_**(fn): void
Validates a middleware function, throws if fn is not of type function.
Parameters
fn
unknownRequiredReturns
void
void
void