lib/loader.js
function (dir, failOnDups) {
            debug('Loading services from %s', dir);
            di.iterateOverJsFiles(dir, function(dir, file) {
                var modPath = path.resolve(dir, file);
                var mod;
                try {
                    mod = subRequire(modPath); //subRequire inserts the _id field
                } catch (e) {
                    throw new Error('Could not load ' + modPath + ': ' + e.message);
                }
                registerServiceModule(mod, failOnDups);
            });

        }
function (dir, failOnDups) {
            debug('Loading services from %s', dir);
            di.iterateOverJsFiles(dir, function(dir, file) {
                var modPath = path.resolve(dir, file);
                var mod;
                try {
                    mod = subRequire(modPath); //subRequire inserts the _id field
                } catch (e) {
                    throw new Error('Could not load ' + modPath + ': ' + e.message);
                }
                registerServiceModule(mod, failOnDups);
            });

        }
function ( dir , failOnDups ) { debug ( 'Loading services from %s' , dir ) ; di . iterateOverJsFiles ( dir , function ( dir , file ) { var modPath = path . resolve ( dir , file ) ; var mod ; try { mod = subRequire ( modPath ) ; //subRequire inserts the _id field } catch ( e ) { throw new Error ( 'Could not load ' + modPath + ': ' + e . message ) ; } registerServiceModule ( mod , failOnDups ) ; } ) ; }
Load all the services in a given directory.

The service is registered based on its filename, e.g. service.js is registered as service.
Dependencies are calculated based on the parameter names of the init method of the service.
@param dir
@param failOnDups - if specified, error out if there are name collisions with an existing service
Load all the services in a given directory .