function setup_server(config, opts) {
	config._def('port', 3000);
	var req_handler = do_create_req(config, opts);
	var server = do_create_server(config, function(req, res) {
		req_handler(req, res).then(function(obj) {
			if(obj === api.replySent) {
				// Silently return since reply has been handler already.
				return;
			} else if(obj === api.notFound) {
				do_failure(req, res, {'verb': 'notFound', 'desc':'The requested resource could not be found.', 'code':404});
			} else {
				do_success(req, res, obj);
			}
		}).fail(function(err) {
			do_failure(req, res, err);
			if(!(err instanceof errors.HTTPError)) {
				require('prettified').errors.print(err);
			}
		}).done();
	});
	return server;
}
function setup_server(config, opts) {
	config._def('port', 3000);
	var req_handler = do_create_req(config, opts);
	var server = do_create_server(config, function(req, res) {
		req_handler(req, res).then(function(obj) {
			if(obj === api.replySent) {
				// Silently return since reply has been handler already.
				return;
			} else if(obj === api.notFound) {
				do_failure(req, res, {'verb': 'notFound', 'desc':'The requested resource could not be found.', 'code':404});
			} else {
				do_success(req, res, obj);
			}
		}).fail(function(err) {
			do_failure(req, res, err);
			if(!(err instanceof errors.HTTPError)) {
				require('prettified').errors.print(err);
			}
		}).done();
	});
	return server;
}
function setup_server ( config , opts ) { config . _def ( 'port' , 3000 ) ; var req_handler = do_create_req ( config , opts ) ; var server = do_create_server ( config , function ( req , res ) { req_handler ( req , res ) . then ( function ( obj ) { if ( obj === api . replySent ) { // Silently return since reply has been handler already. return ; } else if ( obj === api . notFound ) { do_failure ( req , res , { 'verb' : 'notFound' , 'desc' : 'The requested resource could not be found.' , 'code' : 404 } ) ; } else { do_success ( req , res , obj ) ; } } ) . fail ( function ( err ) { do_failure ( req , res , err ) ; if ( ! ( err instanceof errors . HTTPError ) ) { require ( 'prettified' ) . errors . print ( err ) ; } } ) . done ( ) ; } ) ; return server ; }
API server builder
API server builder