Static routing

At this stage, it remains only to clarify how the framework will know that it is necessary to display this particular template at the root address. This is specified in the application settings, in the settings.config file:

... //------------------------------------------------------------- // //en Router settings // //------------------------------------------------------------- routes:[ { uri: "", controller: "fcf:NServer/NControllers/Page.js", source: "templates/pages/main-page.tmpl", title: "FCF Application", description: "Main page of the FCF application", }, { uri: "favicon.ico", controller: "fcf:NServer/NControllers/File.js", source: "favicon.ico", }, { uri: "/templates/*", controller: "fcf:NServer/NControllers/File.js", source: "templates", }, { uri: "/translations/*", controller: "fcf:NServer/NControllers/File.js", source: "translations", }, { uri: "robots.txt", controller: "fcf:NServer/NControllers/File.js", source: "robots.txt", }, ], ...

The routes array in the configuration defines a set of static routes for the application; we will not discuss other methods of creating routes for now. This array stores elements with information about a specific route. Let's consider the properties of the route configuration.

  • string url - route address.

    Constructions with an incomplete address format are allowed, which may end with a *. The rest of the address falls into the subUri property of the fcf.RouteInfo object

    It is also possible to set the address using variable parts of the address. To do this, the ${PARAM_NAME} construct is used in the URL parameter. Example:

    ... url: "/home/${part}", ...

    When accessing this address, a "part" record with a value corresponding to the section of the called URL will be added to the args property of the fcf.RouteInfo object

  • string url - Path to the controller handling the request

  • string title - The title of the route element. Also used in the controller "fcf:NServer/NControllers/Page.js" to fill the title tag in the page title.

  • string description - Description of the route element. It is also used in the "fcf:NServer/NControllers/Page.js" controller to fill in the meta description tag in the page title.

The rest of the parameters for each type of controller are specific.

So for the "fcf:NServer/NControllers/Page.js" controller, the "source" property stores the path to the template that will be displayed as a page.

For the "fcf:NServer/NControllers/File.js" controller, the "source" property stores the path to a file or directory that will be accessible from the browser side.