Application

This configuration file contains general setting for the application.

Definition

  • name: The name of the application
  • logo: The logo of the application
  • logo: The favicon of the application
  • statics: Array containing an object for configure the static folders of the project. The object contains:
    • url: The url for mapping the folder
    • folder: The relative path from the application directory of the folder to be mapped

The order of the statics array is the order that will be applied in express statics.

  • view_engine: Engine to use for frontend page rendering
  • enableCors: Enable Cross-Origin Resource Sharing (CORS) that enables open access across domain-boundaries
  • notFound: How to process 404 errors. If not set, a simple JSON message is shown. If set to a URL, then you are redirected to it. If set to 'disabled' no process is done, so this behaviour can be set in main startup file (bin/www).
  • json_limit: Enable to change size limit to json body-parser (Default 100kb).

Example

module.exports = {
    name: "My Application",
    logo: "/assets/images/logo_small.png",
    favicon: "/assets/images/logo_small.png",
    statics: [
        {
            url: '/',
            folder: 'public'
        }
    ],
    view_engine: 'jade',
    enableCors: true,
    json_limit: { limit: '200kb' }
};

Angular example

This configuration disables not found handler and process 404 errors in startup file. It redirects to index.html standard requests (allowing Angular routes to work) and redirects to a snapshot folder for correct SEO crawlers behaviour.

application.js

module.exports = {
    name: "My Application",
    logo: "/assets/images/logo_small.png",
    favicon: "/assets/images/logo_small.png",
    statics: [
        {
            url: '/',
            folder: 'public'
        }
    ],
    view_engine: 'jade',
    enableCors: true,
    notFound: 'disabled'
};

bin/www

var routeinjector = require('route-injector');
var path = require('path');
var snapshotUtils      = require('./../utils/snapshotUtils.js');

routeinjector.start(function() {
     snapshotUtils.startSeoTasks();

     routeinjector.app.get("/*",  function(req, res) {
          if(snapshotUtils.isCrawler(req)) {
               var temp = req.url.replace('?_escaped_fragment_=/', '');
               var route = path.join(__dirname, '..', '/snapshots', temp);
               res.sendFile('index.html', { root: route });
          } else {
               var route = path.join(__dirname, '..', '/public', '/dist');
               res.sendFile('index.html', { root: route });
          }
     });
});

TODO This behaviour can be included in a 'angular' mode?

results matching ""

    No results matching ""