checks.js
function(request, response, next){
		var apptkn;
		if (!utils.Misc.isNullOrUndefined(request.get(X_BOLT_APP_TOKEN))) {
			apptkn = request.get(X_BOLT_APP_TOKEN);
		}
		else {
			var error = new Error(errors['110']);
			response.end(utils.Misc.createResponse(null, error, 110));
			return;
		}

		var name = __getAppFromAppToken(apptkn, request);
		if (utils.Misc.isNullOrUndefined(name)) {
			var error = new Error(errors['113']);
			response.end(utils.Misc.createResponse(null, error, 113));
			return;
		}
		var appnm = utils.String.trim(name.toLowerCase());

		if (appnm == 'bolt') {
			//native views
			next();
		}
		else {
			models.app.findOne({ 
				name: appnm, system: true
			}, function(appError, app){
				if (!utils.Misc.isNullOrUndefined(appError)) {
					response.end(utils.Misc.createResponse(null, appError));
				}
				else if(utils.Misc.isNullOrUndefined(app)){
					var error = new Error(errors['504']);
					response.end(utils.Misc.createResponse(null, error, 504));
				}
				else{
					next();
				}
			});
		}
	}
function(request, response, next){
		var apptkn;
		if (!utils.Misc.isNullOrUndefined(request.get(X_BOLT_APP_TOKEN))) {
			apptkn = request.get(X_BOLT_APP_TOKEN);
		}
		else {
			var error = new Error(errors['110']);
			response.end(utils.Misc.createResponse(null, error, 110));
			return;
		}

		var name = __getAppFromAppToken(apptkn, request);
		if (utils.Misc.isNullOrUndefined(name)) {
			var error = new Error(errors['113']);
			response.end(utils.Misc.createResponse(null, error, 113));
			return;
		}
		var appnm = utils.String.trim(name.toLowerCase());

		if (appnm == 'bolt') {
			//native views
			next();
		}
		else {
			models.app.findOne({ 
				name: appnm, system: true
			}, function(appError, app){
				if (!utils.Misc.isNullOrUndefined(appError)) {
					response.end(utils.Misc.createResponse(null, appError));
				}
				else if(utils.Misc.isNullOrUndefined(app)){
					var error = new Error(errors['504']);
					response.end(utils.Misc.createResponse(null, error, 504));
				}
				else{
					next();
				}
			});
		}
	}
function ( request , response , next ) { var apptkn ; if ( ! utils . Misc . isNullOrUndefined ( request . get ( X_BOLT_APP_TOKEN ) ) ) { apptkn = request . get ( X_BOLT_APP_TOKEN ) ; } else { var error = new Error ( errors [ '110' ] ) ; response . end ( utils . Misc . createResponse ( null , error , 110 ) ) ; return ; } var name = __getAppFromAppToken ( apptkn , request ) ; if ( utils . Misc . isNullOrUndefined ( name ) ) { var error = new Error ( errors [ '113' ] ) ; response . end ( utils . Misc . createResponse ( null , error , 113 ) ) ; return ; } var appnm = utils . String . trim ( name . toLowerCase ( ) ) ; if ( appnm == 'bolt' ) { //native views next ( ) ; } else { models . app . findOne ( { name : appnm , system : true } , function ( appError , app ) { if ( ! utils . Misc . isNullOrUndefined ( appError ) ) { response . end ( utils . Misc . createResponse ( null , appError ) ) ; } else if ( utils . Misc . isNullOrUndefined ( app ) ) { var error = new Error ( errors [ '504' ] ) ; response . end ( utils . Misc . createResponse ( null , error , 504 ) ) ; } else { next ( ) ; } } ) ; } }
checks to be sure the app making this request is a system app
checks to be sure the app making this request is a system app