@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

resourceFactory :@ui5/server/middleware/MiddlewareUtil~resourceFactory

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:
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:
Parameters:
Name Type Attributes Description
projectName string <optional>
Name 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:
Parameters:
Name Type Description
resourcePath object
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:
Parameters:
Name Type Description
req object Request 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:
Parameters:
Name Type Attributes Description
projectNameOrResource string | @ui5/fs/Resource <optional>
Name 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
Source:
Properties:
Name Type Description
type string Detected content-type for the given resource path
charset string Default charset for the detected content-type
contentType string Calculated content-type header value
MIME Info
Type:
  • object
Example
const mimeInfo = {
	"type": "text/html",
	"charset": "utf-8",
	"contentType": "text/html; charset=utf-8"
};

ProjectInterface

Description:
  • Specification Version-dependent Project interface. For details on individual functions, see Project
Source:
Properties:
Name Type Description
getType function Get the project type
getName function Get the project name
getVersion function Get the project version
getNamespace function Get the project namespace
getRootReader function Get the project rootReader
getReader function Get the project reader, defaulting to "runtime" style instead of "buildtime"
getRootPath function Get the local File System path of the project's root directory
getSourcePath function Get the local File System path of the project's source directory
getCustomConfiguration function Get the project Custom Configuration
isFrameworkProject function Check whether the project is a UI5-Framework project
getFrameworkName function Get the project's framework name configuration
getFrameworkVersion function Get the project's framework version configuration
getFrameworkDependencies function Get 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:
Properties:
Name Type Description
createResource function Creates a Resource. Accepts the same parameters as the Resource constructor.
createReaderCollection function Creates a reader collection: ReaderCollection
createReaderCollectionPrioritized function Creates a prioritized reader collection: ReaderCollectionPrioritized
createFilterReader function Create a Filter-Reader with the given reader.
createLinkReader function Create a Link-Reader with the given reader.
createFlatReader function Create a Link-Reader where all requests are prefixed with /resources/.
Specification Version-dependent set of @ui5/fs/resourceFactory functions provided to middleware. For details on individual functions, see @ui5/fs/resourceFactory
Type:
  • object