code: function configureRoutes(app, config) {
      config = config || {};
  
      // TODO: add declarative routes
      // 'GET /foo bar/baz:qux' --> get('/foo', require('bar/baz')['qux'])
      // ...
  
      if (config.resources) {
          Object.keys(config.resources).forEach(function (urlPrefix) {
              DEBUG && debug('configure resource route: ', urlPrefix, '--->', config.resources[urlPrefix]);
              require('./resource').configureResource(app, urlPrefix, require(config.resources[urlPrefix]));
          });
      }
  
      if (config.statics) {
          Object.keys(config.statics).forEach(function (urlPrefix) {
              var dir = path.resolve(process.cwd(), config.statics[urlPrefix]);
              DEBUG && debug('configure http static route: ', urlPrefix, '--->', dir);
              app.use(urlPrefix, require('serve-static')(dir));
          });
      }
  
      if (config.root) {
          var root = path.resolve(process.cwd(), config.root);
          DEBUG && debug('configure http static root:', root);
          app.use(require('serve-static')(root));
  
          var favicon = path.join(root, 'favicon.ico');
          DEBUG && debug('configure http favicon route:', favicon);
          app.use(require('serve-favicon')(favicon));
      }
  
      DEBUG && debug('configure error routes', config.errors);
      if (config.errors) {
          var config404 = config.errors['404'];
          if (config404) {
              app.use(require('./error404')(config404));
          }
          var config500 = config.errors['500'];
          if (config500) {
              app.use(require('./error500')(config500));
          }
      }
  
      // NOTE: this should be end-of-middleware chain
      app.use(require('errorhandler')({dumpException: true, showStack: true}));
  
      return app;
  }
docs: setup common express/connect routes including 404, 500 and errorHandler.
  
  NOTE: this should be called after your middlewares and routes.
  
  @param {*} app express application instance
  @param {*} config
  @return {*} app