lib/server/start.js
function start(Router, APIAdapter, startOptions) {
	debug('Starting server');

	if(!_.has(startOptions, 'app')) {
		throw new Error('Missing "app" property in "startOptions"! Please ' +
			'pass a valid express app instance when starting the barefoot ' +
			'router on the server.');
	}
	if(!_.has(startOptions, 'mainJavaScriptFile')) {
		throw new Error('Missing "mainJavaScriptFile" property in ' +
			'"startOptions"! Please describe how browserify should serve your' +
			' applications code.');
	}

	var app = startOptions.app
		, apiAdapter;

	if(_.has(startOptions, 'setupMiddlewares')) {
		startOptions.setupMiddlewares(app);
	}

	if(_.has(startOptions, 'setupApiAdapter')) {
		apiAdapter = new APIAdapter(startOptions);
		startOptions.setupApiAdapter(apiAdapter);

		if(!_.isUndefined(apiAdapter, 'sync')) {
			Backbone.sync = function() {
				return apiAdapter.sync.apply(apiAdapter, arguments);
			};
		}

		startOptions.apiAdapter = apiAdapter;
	}

	prepareBrowserify(app, startOptions.mainJavaScriptFile);

	// Just inject everything from the startup options into the router.
	var concreteServerRouter = new Router(startOptions);
	concreteServerRouter.start();
}
function start(Router, APIAdapter, startOptions) {
	debug('Starting server');

	if(!_.has(startOptions, 'app')) {
		throw new Error('Missing "app" property in "startOptions"! Please ' +
			'pass a valid express app instance when starting the barefoot ' +
			'router on the server.');
	}
	if(!_.has(startOptions, 'mainJavaScriptFile')) {
		throw new Error('Missing "mainJavaScriptFile" property in ' +
			'"startOptions"! Please describe how browserify should serve your' +
			' applications code.');
	}

	var app = startOptions.app
		, apiAdapter;

	if(_.has(startOptions, 'setupMiddlewares')) {
		startOptions.setupMiddlewares(app);
	}

	if(_.has(startOptions, 'setupApiAdapter')) {
		apiAdapter = new APIAdapter(startOptions);
		startOptions.setupApiAdapter(apiAdapter);

		if(!_.isUndefined(apiAdapter, 'sync')) {
			Backbone.sync = function() {
				return apiAdapter.sync.apply(apiAdapter, arguments);
			};
		}

		startOptions.apiAdapter = apiAdapter;
	}

	prepareBrowserify(app, startOptions.mainJavaScriptFile);

	// Just inject everything from the startup options into the router.
	var concreteServerRouter = new Router(startOptions);
	concreteServerRouter.start();
}
function start ( Router , APIAdapter , startOptions ) { debug ( 'Starting server' ) ; if ( ! _ . has ( startOptions , 'app' ) ) { throw new Error ( 'Missing "app" property in "startOptions"! Please ' + 'pass a valid express app instance when starting the barefoot ' + 'router on the server.' ) ; } if ( ! _ . has ( startOptions , 'mainJavaScriptFile' ) ) { throw new Error ( 'Missing "mainJavaScriptFile" property in ' + '"startOptions"! Please describe how browserify should serve your' + ' applications code.' ) ; } var app = startOptions . app , apiAdapter ; if ( _ . has ( startOptions , 'setupMiddlewares' ) ) { startOptions . setupMiddlewares ( app ) ; } if ( _ . has ( startOptions , 'setupApiAdapter' ) ) { apiAdapter = new APIAdapter ( startOptions ) ; startOptions . setupApiAdapter ( apiAdapter ) ; if ( ! _ . isUndefined ( apiAdapter , 'sync' ) ) { Backbone . sync = function ( ) { return apiAdapter . sync . apply ( apiAdapter , arguments ) ; } ; } startOptions . apiAdapter = apiAdapter ; } prepareBrowserify ( app , startOptions . mainJavaScriptFile ) ; // Just inject everything from the startup options into the router. var concreteServerRouter = new Router ( startOptions ) ; concreteServerRouter . start ( ) ; }
Function: start
On start on the server, this function creates an <APIAdapter> if apiRoutes
are present in the startOptions. Further the actual <Barefoot.Router> is
created an started using <Barefoot.Router.Server.start>.

Before doing all this, startOptions is checked if an Express.JS app is
present (if not, an error gets thrown which will stop the start process).

Parameters:
(Barefoot.Router) Router - A <Barefoot.Router> object. Important: This is
is not an instance of the router, it is the
"plain" object which can be used for running
"new Router(...)".
(Object) startOptions - This object literal is passed to the router when
initializing it.
Function : start On start on the server this function creates an <APIAdapter > if apiRoutes are present in the startOptions . Further the actual <Barefoot . Router > is created an started using <Barefoot . Router . Server . start > .