<commit_before>/* https://groups.google.com/forum/#!msg/express-js/u5SO-nu9ptU/8CN5P7lv36AJ
------------------------------------------------------------------------------ */

require('express-namespace');

var _           = require('lodash')
  , fs          = require('fs')
  , path        = require('path')
  , assert      = require('assert')
  , params      = require('express-params')
  , sprintf     = require('sprintf').sprintf
  , funcPath    = require('node-module-util').funcPath
  , loadRoutes  = require('node-routes-autoload').loadRoutes
  ;

function init(options) {
  options = (options || {});

  var assertErrFormat = funcPath(__dirname, __filename, init) + ' :: Fatal error! Missing parameter: %s'
    , uuidFormat  = /^[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}$/
    , controllers
    , app
    ;

  assert(options.app, sprintf(assertErrFormat, 'options.app'));

  app = options.app;

  // ### routes initialization
  params.extend(app);
  app.param('uuid', uuidFormat);
  controllers = loadRoutes({ app: app, routeDir: __dirname + '/controllers' });<commit_msg>Updated router to match new version of controllers autoloader<commit_after>/* https://groups.google.com/forum/#!msg/express-js/u5SO-nu9ptU/8CN5P7lv36AJ
------------------------------------------------------------------------------ */

require('express-namespace');

var _           = require('lodash')
  , fs          = require('fs')
  , path        = require('path')
  , assert      = require('assert')
  , params      = require('express-params')
  , sprintf     = require('sprintf').sprintf
  , funcPath    = require('node-module-util').funcPath
  , loadControllers  = require('node-routes-autoload').loadControllers
  ;

function init(options) {
  options = (options || {});

  var assertErrFormat = funcPath(__dirname, __filename, init) + ' :: Fatal error! Missing parameter: %s'
    , uuidFormat  = /^[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}$/
    , controllers
    , app
    ;

  assert(options.app, sprintf(assertErrFormat, 'options.app'));

  app = options.app;

  // ### routes initialization
  params.extend(app);
  app.param('uuid', uuidFormat);
  controllers = loadControllers({
      app: app
    , controllerDir: __dirname + '/controllers'
    , skipControllers: ['']
  });
{'fraction_non_alphanumeric': 0.23897216274089936, 'fraction_numerical': 0.019700214132762312, 'mean_word_length': 2.491778774289985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7279693', 'n_tokens_mistral': 786, 'n_tokens_neox': 770, 'n_words': 117}