'use strict';

var fs = require('fs');
var path = require('path');
var Router = require('../src/router');
var Hub = require('../src/hub');
module.exports = function loader(dir) {
  var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

  require(path.join(dir, config.linkPath || 'link.js'));
  var handlerPath = path.join(dir, config.handlerPath || 'handlers');
  fs.readdirSync(handlerPath).forEach(function (file) {
    require(path.join(handlerPath, file));
  });
  Router.check();
  Hub.check();
};