Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
4.9 KiB
displayed_sidebar
| displayed_sidebar |
|---|
| jsClientSidebar |
Class: MiddlewareService
internal.internal.MiddlewareService
Orchestrates dynamic middleware registered through the Medusa Middleware API
Properties
postAuthentication_
• Protected Readonly postAuthentication_: middlewareType[]
Defined in
packages/medusa/dist/services/middleware.d.ts:11
preAuthentication_
• Protected Readonly preAuthentication_: middlewareType[]
Defined in
packages/medusa/dist/services/middleware.d.ts:12
preCartCreation_
• Protected Readonly preCartCreation_: RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>[]
Defined in
packages/medusa/dist/services/middleware.d.ts:13
routers
• Protected Readonly routers: Record<string, Router[]>
Defined in
packages/medusa/dist/services/middleware.d.ts:14
Methods
addPostAuthentication
▸ addPostAuthentication(middleware, options): void
Adds a middleware function to be called after authentication is completed.
Parameters
| Name | Type | Description |
|---|---|---|
middleware |
middlewareHandlerType |
the middleware function. Should return a middleware function. |
options |
Record<string, unknown> |
the arguments that will be passed to the middleware |
Returns
void
void
Defined in
packages/medusa/dist/services/middleware.d.ts:32
addPreAuthentication
▸ addPreAuthentication(middleware, options): void
Adds a middleware function to be called before authentication is completed.
Parameters
| Name | Type | Description |
|---|---|---|
middleware |
middlewareHandlerType |
the middleware function. Should return a middleware function. |
options |
Record<string, unknown> |
the arguments that will be passed to the middleware |
Returns
void
void
Defined in
packages/medusa/dist/services/middleware.d.ts:41
addPreCartCreation
▸ addPreCartCreation(middleware): void
Adds a middleware function to be called before cart creation
Parameters
| Name | Type | Description |
|---|---|---|
middleware |
RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>> |
the middleware function. Should return a middleware function. |
Returns
void
Defined in
packages/medusa/dist/services/middleware.d.ts:48
addRouter
▸ addRouter(path, router): void
Parameters
| Name | Type |
|---|---|
path |
string |
router |
Router |
Returns
void
Defined in
packages/medusa/dist/services/middleware.d.ts:16
getRouters
▸ getRouters(path): Router[]
Parameters
| Name | Type |
|---|---|
path |
string |
Returns
Router[]
Defined in
packages/medusa/dist/services/middleware.d.ts:17
usePostAuthentication
▸ usePostAuthentication(app): void
Adds post authentication middleware to an express app.
Parameters
| Name | Type | Description |
|---|---|---|
app |
Router |
the express app to add the middleware to |
Returns
void
Defined in
packages/medusa/dist/services/middleware.d.ts:54
usePreAuthentication
▸ usePreAuthentication(app): void
Adds pre authentication middleware to an express app.
Parameters
| Name | Type | Description |
|---|---|---|
app |
Router |
the express app to add the middleware to |
Returns
void
Defined in
packages/medusa/dist/services/middleware.d.ts:60
usePreCartCreation
▸ usePreCartCreation(): RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>[]
Returns
RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>[]
Defined in
packages/medusa/dist/services/middleware.d.ts:61
validateMiddleware_
▸ validateMiddleware_(fn): void
Validates a middleware function, throws if fn is not of type function.
Parameters
| Name | Type | Description |
|---|---|---|
fn |
unknown |
the middleware function to validate. |
Returns
void
nothing if the middleware is a function
Defined in
packages/medusa/dist/services/middleware.d.ts:23