Files
medusa-store/docs/content/references/services/classes/MiddlewareService.md
2022-06-01 18:33:08 +02:00

5.0 KiB

Class: MiddlewareService

Orchestrates dynamic middleware registered through the Medusa Middleware API

Constructors

constructor

new MiddlewareService(container)

Parameters

Name Type
container any

Defined in

services/middleware.js:7

Properties

postAuthentication_

postAuthentication_: any[]

Defined in

services/middleware.js:8


preAuthentication_

preAuthentication_: any[]

Defined in

services/middleware.js:9


preCartCreation_

preCartCreation_: any[]

Defined in

services/middleware.js:10


routers

routers: Object

Defined in

services/middleware.js:11

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

services/middleware.js:45


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

services/middleware.js:61


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

services/middleware.js:75


addRouter

addRouter(path, router): void

Parameters

Name Type
path any
router any

Returns

void

Defined in

services/middleware.js:14


getRouters

getRouters(path): any

Parameters

Name Type
path any

Returns

any

Defined in

services/middleware.js:19


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

services/middleware.js:85


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

services/middleware.js:96


usePreCartCreation

usePreCartCreation(): any[]

Returns

any[]

Defined in

services/middleware.js:102


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

Defined in

services/middleware.js:28