Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Mesh

Main entry point for the frontend API. Use this class to power your express mesh server.

Usage: import * as mesh from 'express-mesh'; var Mesh = new mesh.Mesh(new mesh.MeshConfig('Demo', 'public', 'languages')); Mesh.server(app);

Hierarchy

  • Mesh

Index

Constructors

constructor

  • Constructor for the main frontend API entry point.

    Parameters

    • app: express.Express

      Express app.

    • config: MeshConfig

      Configuration for the mesh server.

    Returns Mesh

Properties

Private app

app: express.Express

Express app.

Private config

config: MeshConfig

Configuration for the mesh server.

Private meshClient

meshClient: MeshRestClient

Private renderer

renderer: MeshRenderer

Methods

get

  • Make a GET request to the mesh backend.

    Type parameters

    • T

    Parameters

    • req: IMeshRequest

      The Mesh Request

    • url: string

      The url you want to GET

    • Optional params: MeshQueryParams

      Query params for your request.

    Returns Promise<MeshRestResponse<T>>

    A promise that will be fulfilled once the request has been completed and will fail if the request fails.

getChildren

  • Load all child nodes of a specified node.

    Type parameters

    • T

    Parameters

    • req: IMeshRequest

      The mesh request / Express request.

    • uuid: string

      The specified node, which children should be loaded.

    • Optional params: MeshQueryParams

      QueryParams to specify the language and other options.

    Returns Promise<IMeshNodeListResponse<IMeshNode<T>>>

    A promise that will be fulfilled once the children have been loaded and will be rejected if loading the children fails.

getNavigationByPath

  • Load a navigation object by its path. e.g. / for the root navigation. You can only load navigation objects for container nodes.

    Parameters

    • req: IMeshRequest

      The mesh request / Express request.

    • path: string

      The path for which the navigation object should be loaded.

    • params: MeshQueryParams

      QueryParams to specify the language, navigation depth, includeAll and other options.

    Returns Promise<MeshRestResponse<IMeshNav>>

    A promise that will be fulfilled once the navigation object has been loaded and will be rejected if loading of the navigation object fails.

getNavigationByUUID

  • Load a navigation object by its uuid. You can only load navigation objects for container nodes.

    Parameters

    • req: IMeshRequest

      The mesh request / Express request.

    • uuid: string

      The uuid of the root node of the navigation tree you want to load.

    • params: MeshQueryParams

      QueryParams to specify the language, navigation depth, includeAll and other options.

    Returns Promise<MeshRestResponse<IMeshNav>>

    A promise that will be fulfilled once the navigation object has been loaded and will be rejected if loading of the navigation object fails.

getNode

  • Load a Mesh node with the specified uuid.

    Type parameters

    • T

    Parameters

    • req: IMeshRequest

      The mesh request / Express request.

    • uuid: string

      The uuid of the node that should be loaded.

    • Optional params: MeshQueryParams

      QueryParams to specify the language and other options.

    Returns Promise<IMeshNode<T>>

    A promise that will be fulfilled once the Mesh node is loaded and will be rejected if loading of the Mesh node fails.

Private getRequestHandler

  • getRequestHandler(): function
  • Private method that constructs the quest handler, that will serve the Mesh content from webroot.

    Returns function

      • (req: express.Request, res: express.Response): void
      • Parameters

        • req: express.Request
        • res: express.Response

        Returns void

getTagFamilies

getTagsOfTagFamily

login

  • login(req: IMeshRequest, username: string, password: string): Promise<boolean>
  • Login to Gentics Mesh with the provided user. All subsequent requests with the same session will use the provided credentials for requests to Mesh.

    Parameters

    • req: IMeshRequest

      The mesh request / Express request.

    • username: string

      Login

    • password: string

      Password

    Returns Promise<boolean>

    A promise that will be fulfilled as soon es the login completes and will be rejected if the login fails.

logout

  • Logout from Gentics Mesh. All subsequent requests with the same session will use the default user that has been configured in the MeshConfig for requests to Mesh.

    Parameters

    Returns Promise<boolean>

    A promise that will be fulfilled as soon as the logout completes and will be rejected if the logout fails.

registerErrorHandler

  • Register a custom error handler. A error handler will be executed if an error with the status it has been registered for occurs.

    Parameters

    • status: number

      The status the handler should be registered for

    • handler: IMeshErrorHandler

      The handler that should be registered

    Returns void

Private registerMeshMiddleware

  • registerMeshMiddleware(app: express.Express): void
  • Private method that will register the mesh middleware in the Express app. This middleware will enrich the mesh request with the configuration and the active language.

    Parameters

    • app: express.Express

      The Express app.

    Returns void

registerSchemaHandler

  • Register a custom schema handler. A registered schema handler will be executed before a node with the schema it has been registered for will be rendered. This can be used to fetch additional information and perform operations on the data provided by Mesh.

    Type parameters

    • T

    Parameters

    • schema: string

      Schema the handler should be registered for

    • handler: IMeshSchemaHandler<T>

      The handler that should be registered

    Returns void

registerTemplateFilters

  • Register default template filters. Out of the box we support registering filters with swig and handlebars. If you have a different template engine please pass a register function to register the filters with your template engine. This function will then be called for each of the mesh filters.

    Parameters

    • engine: any

      Your template engine.

    • Optional registerfunction: IFilterRegisterFunction

      register function that will be called for each of the mesh filters.

    Returns void

registerViewHandler

  • Register a custom view handler. A view handler will be executed every time before a view is being rendered by the Mesh frontend. This can be used to fetch additional information and perform operations on the data provided by Mesh.

    Parameters

    Returns void

renderNode

  • Render a Mesh node. This function will render the provided node with the view that is named after the node's schema. If the view with this name is not available, the default view will be rendered. All registered handlers that apply for this function will be executed.

    Parameters

    Returns void

renderView

  • Render a view. This function will render the provided view. If the view with this name is not available, the default view will be rendered. All registered handlers that apply for this function will be executed.

    Parameters

    • view: string

      name of the view that should be rendered.

    • renderdata: RenderData

      Data that should be passed to the view.

    • req: IMeshRequest

      The mesh request / Express request.

    • res: IMeshResponse

      The mesh response / Express response.

    Returns void

request

  • Make a request to the mesh backend.

    Type parameters

    • T

    Parameters

    • method: string

      The request method (GET/POST/PUT/DELETE/...)

    • req: IMeshRequest

      The Mesh Request

    • url: string

      The url you want to GET

    • Optional params: MeshQueryParams

      Query params for your request.

    • Optional data: any

      Data you want to send with the request (PUT/POST)

    Returns Promise<MeshRestResponse<T>>

    A promise that will be fulfilled once the request has been completed and will fail if the request fails.

searchNodes

server

  • server(app: express.Express): void
  • Initialize the Mesh server. Call this method after you added your own request handlers to the Express app, as this method will attach a * handler to catch all requests that have not been handled by another handler.

    Parameters

    • app: express.Express

      The Express app.

    Returns void

Generated using TypeDoc