index.js
function apier(config) {
	// on server start..
	db.connect(config.mongoUrl);
	accessVerifier.init(config.access);
	schemaExtender.handleErrors = true;
	reqlog.info('apier initialized!!');

	var app = function(req, res) {
		// this is the final handler if no match found
		router(req, res, function(error) {
			if (error) {
				reqlog.error(error);
				responseBuilder.error(req, res, 'INTERNAL_SERVER_ERROR');
			} else {
				reqlog.info('NOT_FOUND:', req.method + ' ' + req.url);
				responseBuilder.error(req, res, 'NOT_FOUND');
			}
		});
	};

	app.endpoint = endpoint;

	return app;
}
function apier(config) {
	// on server start..
	db.connect(config.mongoUrl);
	accessVerifier.init(config.access);
	schemaExtender.handleErrors = true;
	reqlog.info('apier initialized!!');

	var app = function(req, res) {
		// this is the final handler if no match found
		router(req, res, function(error) {
			if (error) {
				reqlog.error(error);
				responseBuilder.error(req, res, 'INTERNAL_SERVER_ERROR');
			} else {
				reqlog.info('NOT_FOUND:', req.method + ' ' + req.url);
				responseBuilder.error(req, res, 'NOT_FOUND');
			}
		});
	};

	app.endpoint = endpoint;

	return app;
}
function apier ( config ) { // on server start.. db . connect ( config . mongoUrl ) ; accessVerifier . init ( config . access ) ; schemaExtender . handleErrors = true ; reqlog . info ( 'apier initialized!!' ) ; var app = function ( req , res ) { // this is the final handler if no match found router ( req , res , function ( error ) { if ( error ) { reqlog . error ( error ) ; responseBuilder . error ( req , res , 'INTERNAL_SERVER_ERROR' ) ; } else { reqlog . info ( 'NOT_FOUND:' , req . method + ' ' + req . url ) ; responseBuilder . error ( req , res , 'NOT_FOUND' ) ; } } ) ; } ; app . endpoint = endpoint ; return app ; }
Create an apier app
@method apier
@param {object} config The app configuration
It must contain the following options
mongoUrl: String. The mongo url to connect to
handleErrors: Boolean. Define if the schemaExtender will handle the db errors
@return {Function} The app to use as server
Create an apier app