Skip to content

@ui5/server/middleware/MiddlewareUtil

@ui5/server/middleware/MiddlewareUtil

Convenience functions for UI5 Server middleware. An instance of this class is passed to every standard UI5 Server middleware. Custom middleware that define a specification version >= 2.0 will also receive an instance of this class as part of the parameters of their create-middleware function.

The set of functions that can be accessed by a custom middleware depends on the specification version defined for the extension.

Members

Description: Provides limited access to @ui5/fs/resourceFactory functions

This attribute is only available to custom server middleware extensions defining Specification Version 3.0 and above.

Source: server/lib/middleware/MiddlewareUtil.js, line 199

Provides limited access to @ui5/fs/resourceFactory functions

This attribute is only available to custom server middleware extensions defining Specification Version 3.0 and above.

Type:

Methods

getDependencies(projectNameopt) → {Array<string>}

Description: Retrieve a list of direct dependencies of a given project from the dependency graph. Note that this list does not include transitive dependencies.

This method is only available to custom server middleware extensions defining Specification Version 3.0 and above.

Source: server/lib/middleware/MiddlewareUtil.js, line 164

Parameters:
NameTypeAttributesDescription
projectNamestringoptionalName of the project to retrieve.
Defaults to the name of the current root project
Throws:

If the requested project is unknown to the graph

Type: Error

Returns:

Names of all direct dependencies

Type: Array<string>

getMimeInfo(resourcePath) → {@ui5/server/middleware/MiddlewareUtil.MimeInfo}

Description: Returns MIME information derived from a given resource path. This method is only available to custom middleware extensions defining Specification Version 2.0 and above.

Source: server/lib/middleware/MiddlewareUtil.js, line 91

Parameters:
NameTypeDescription
resourcePathobject
Returns:

Type: @ui5/server/middleware/MiddlewareUtil.MimeInfo

getPathname(req) → {string}

Description: Returns the pathname of a given request. Any escape sequences will be decoded. This method is only available to custom middleware extensions defining Specification Version 2.0 and above.

Source: server/lib/middleware/MiddlewareUtil.js, line 57

Parameters:
NameTypeDescription
reqobjectRequest object
Returns:

Pathname of the given request

Type: string

getProject(projectNameOrResourceopt) → {@ui5/server/middleware/MiddlewareUtil~ProjectInterface|undefined}

Description: Retrieve a single project from the dependency graph

This method is only available to custom server middleware extensions defining Specification Version 3.0 and above.

Source: server/lib/middleware/MiddlewareUtil.js, line 136

Parameters:
NameTypeAttributesDescription
projectNameOrResourcestring | @ui5/fs/ResourceoptionalName of the project to retrieve or a Resource instance to retrieve the associated project for.
Defaults to the name of the current root project
Returns:

Specification Version-dependent interface to the Project instance or undefined if the project name is unknown or the provided resource is not associated with any project.

Type: @ui5/server/middleware/MiddlewareUtil~ProjectInterface | undefined

Type Definitions

MimeInfo

Description: MIME Info

js
const mimeInfo = {
	"type": "text/html",
	"charset": "utf-8",
	"contentType": "text/html; charset=utf-8"
};

Source: server/lib/middleware/MiddlewareUtil.js, line 63

Properties:
NameTypeDescription
typestringDetected content-type for the given resource path
charsetstringDefault charset for the detected content-type
contentTypestringCalculated content-type header value

MIME Info

js
const mimeInfo = {
	"type": "text/html",
	"charset": "utf-8",
	"contentType": "text/html; charset=utf-8"
};
Type:
  • object

ProjectInterface

Description: Specification Version-dependent Project interface. For details on individual functions, see Project

Source: server/lib/middleware/MiddlewareUtil.js, line 100

Properties:
NameTypeDescription
getTypefunctionGet the project type
getNamefunctionGet the project name
getVersionfunctionGet the project version
getNamespacefunctionGet the project namespace
getRootReaderfunctionGet the project rootReader
getReaderfunctionGet the project reader, defaulting to "runtime" style instead of "buildtime"
getRootPathfunctionGet the local File System path of the project's root directory
getSourcePathfunctionGet the local File System path of the project's source directory
getCustomConfigurationfunctionGet the project Custom Configuration
isFrameworkProjectfunctionCheck whether the project is a UI5-Framework project
getFrameworkNamefunctionGet the project's framework name configuration
getFrameworkVersionfunctionGet the project's framework version configuration
getFrameworkDependenciesfunctionGet the project's framework dependencies configuration

Specification Version-dependent Project interface. For details on individual functions, see Project

Type:
  • object

resourceFactory

Description: Specification Version-dependent set of @ui5/fs/resourceFactory functions provided to middleware. For details on individual functions, see @ui5/fs/resourceFactory

Source: server/lib/middleware/MiddlewareUtil.js, line 168

Properties:
NameTypeDescription
createResourcefunctionCreates a Resource.
Accepts the same parameters as the Resource constructor.
createReaderCollectionfunctionCreates a reader collection:
ReaderCollection
createReaderCollectionPrioritizedfunctionCreates a prioritized reader collection:
ReaderCollectionPrioritized
createFilterReaderfunctionCreate a Filter-Reader with the given reader.
createLinkReaderfunctionCreate a Link-Reader with the given reader.
createFlatReaderfunctionCreate a Link-Reader
where all requests are prefixed with /resources/<namespace>.

Specification Version-dependent set of @ui5/fs/resourceFactory functions provided to middleware. For details on individual functions, see @ui5/fs/resourceFactory

Type:
  • object