checks.js
function(request, response, next){
		if (!utils.Misc.isNullOrUndefined(request.body.db)) {
			request.db = request.body.db;
		}
		else if (!utils.Misc.isNullOrUndefined(request.body.app)) {
			request.db = request.body.app;
		}
		else {
			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());
			request.db = appnm;
		}

		if (request.db.indexOf('/') > -1 || request.db.indexOf('\\') > -1 || request.db.indexOf('?') > -1 || request.db.indexOf('&') > -1) {
			//invalid characters in app name
			var error = new Error(errors['405']);
			response.end(utils.Misc.createResponse(null, error, 405));
			return;
		}

		next();
	}
function(request, response, next){
		if (!utils.Misc.isNullOrUndefined(request.body.db)) {
			request.db = request.body.db;
		}
		else if (!utils.Misc.isNullOrUndefined(request.body.app)) {
			request.db = request.body.app;
		}
		else {
			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());
			request.db = appnm;
		}

		if (request.db.indexOf('/') > -1 || request.db.indexOf('\\') > -1 || request.db.indexOf('?') > -1 || request.db.indexOf('&') > -1) {
			//invalid characters in app name
			var error = new Error(errors['405']);
			response.end(utils.Misc.createResponse(null, error, 405));
			return;
		}

		next();
	}
function ( request , response , next ) { if ( ! utils . Misc . isNullOrUndefined ( request . body . db ) ) { request . db = request . body . db ; } else if ( ! utils . Misc . isNullOrUndefined ( request . body . app ) ) { request . db = request . body . app ; } else { 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 ( ) ) ; request . db = appnm ; } if ( request . db . indexOf ( '/' ) > - 1 || request . db . indexOf ( '\\' ) > - 1 || request . db . indexOf ( '?' ) > - 1 || request . db . indexOf ( '&' ) > - 1 ) { //invalid characters in app name var error = new Error ( errors [ '405' ] ) ; response . end ( utils . Misc . createResponse ( null , error , 405 ) ) ; return ; } next ( ) ; }
gets the DB name from the request, and creates the request.db field to hold the value
gets the DB name from the request and creates the request . db field to hold the value