@since 0.0.1
@author Igor Ivanovic
@method Request#_resolveRoute

@description
Resolve valid route
@return {object} Promise
191133
function Request__resolveRoute(routeRule) {
        var route;
        this.route = routeRule.shift();
        this.params = routeRule.shift();
        route = this.route.split('/');
        if (route.length === 3) {
            this.module = route.shift();
        }
        this.controller = route.shift();
        this.action = route.shift();

        if (!!this.module) {
            return this._handleModule(di.getAlias('modulesPath'));
        }

        return this._handleController(di.getAlias('controllersPath'), di.getAlias('viewsPath'));
    }
777497
function promisedRequest(url) {
	var taskId = this[0], req = Object.create(this[1]);
	var method = req.method || 'get';

	if ('args' in req) {
		req.url = url + taskId + find_separator(url) + req.args
	}
	else {
		req.url = url + taskId
	}

	return new Promise(function(resolve, reject) {
		return request[method](req, function(err, response, body) {
			return err ? reject({error: err, headers: response && response.headers})
				: resolve({body: body, headers: response.headers});
		});
	});
}
1282508
function Route(method, route, fn) {
    this.method = method;
    this.route = route;
    this.fn = fn;

    return function (app) {
        var middleware = exports.isAppSettingsRoute(route) ? utils.getSettingsMiddlewares() :
            utils.getRequestMiddlewares();

        if (method == "get") {
            app.get(route, middleware, fn)
        }
        else if (method == "post") {
            app.post(route, middleware, fn);
        }
//        var methodRoutes = app.routes[method];
//        return methodRoutes[methodRoutes.length - 1];
    };
}
246226
function request(path, json) {
    return new Promise(function (resolve, reject) {
      oauth._performSecureRequest(config.telldusToken,
        config.telldusTokenSecret,
        'GET',
        'https://api.telldus.com/json' + path,
        null,
        json,
        !!json ? 'application/json' : null, function (err, body, response) {
          _parseResponse(err, body, response, resolve, reject);
        });
    });
  }
819769
function resolveUrl(url){
    
    // replace all // except the one in proto with /
    url = url.replace(reDoubleSlash, "$1/");
    
    // If the url is a valid url we do nothing
    if (!url.match(/^(http||https):\/\//)) {
        // If this is a relative path
        var path = (url.substring(0, 1) === "/") ? "" : location.pathname;
        if (path.substring(path.length - 1) !== "/") {
            path = path.substring(0, path.lastIndexOf("/") + 1);
        }
        
        url = location.protocol + "//" + location.host + path + url;
    }
    
    // reduce all 'xyz/../' to just '' 
    while (reParent.test(url)) {
        url = url.replace(reParent, "");
    }
    
    return url;
}
714424
function realpath(dir) {
    return new Promise((resolve, reject) => {
        fs.realpath(dir, (err, path) => err ? reject(err) : resolve(path || dir));
    });
}
1080304
function () {
        return hooks.process(this._getApi())
            .then(function handleHooks(data) {
                if (Type.isInitialized(data) && !!data) {
                    return data;
                } else if (this.isPromiseChainStopped) {
                    return false;
                }
                return router
                    .process(this.request.method, this.parsedUrl, this.getRequestHeaders()) // find route
                    .then(this._resolveRoute.bind(this)); // resolve route chain
            }.bind(this)) // handle hook chain
            .then(this._compress.bind(this))
            .then(this._render.bind(this)) // resolve route chain
            .catch(this._handleError.bind(this)) // catch hook error
            .then(this._compress.bind(this))
            .then(this._render.bind(this)) // render hook error
            .catch(this._handleError.bind(this)) // catch render error
            .then(this._compress.bind(this))
            .then(this._render.bind(this)); // resolve render error
    }
1093050
function resolveValue () {
    // promise to resolve with value
    var promise
    // resolve string value
    if (typeof this.value === 'string') {
        promise = this.resolveString()
    }
    // resolve array value
    else if (Array.isArray(this.value)) {
        // resolve array of objects
        if (this.isObjectArray) {
            promise = this.resolveObjectArray()
        }
        // resolve array of id strings
        else {
            promise = this.resolveArray()
        }
    }
    // resolve object value
    else if (this.value && typeof this.value === 'object') {
        promise = this.resolveObject()
    }
    // do nothing
    else {
        return Promise.resolve()
    }
    // wait for promise to resolve then set value in data
    return promise.then(value => {
        // set resolved value
        _.set(this.data, this.setProperty, value)
    })
}
586864
function resolveObject () {
    // get list of ids from values
    var ids = _.filter(_.keys(this.value), value => value.match(idRegExp))
    // if there are no ids then resolve with original values
    if (ids.length === 0) {
        return Promise.resolve(this.value)
    }
    // do query
    return this.model.query(this.getQueryArgs(ids)).then(results => {
        // resolve with data
        return _.keyBy(results, this.isOriginalId ? 'originalId' : 'id')
    })
}
462421
function _resolve(from, to) {
	if (typeof to === 'undefined') {
		to = from;
		from = void(0);
	}

	if (!path.extname(to)) {
		to += '.js';
	}

	return (typeof from === 'undefined') ? path.resolve(to) : path.resolve(from, to);
}
938406
function(router, req, res) {
    var routeFound = false,
      url = req.url.toString(),
      method = req.method;
    for (var i = 0; i < router.routes.length; i++) {
      var route = router.routes[i];
      if (url.indexOf(route.route) != -1 && route.method == method) {
        if (url != '/' && route.route == '/') {
          continue;
        }
        if (url != route.route && !route.hasObject) {
          continue;
        }
        if (method === 'GET') {
          req.body = {};
          if (route.hasObject) {
            req.body[route.objectName] = basename(url);
          }
          route.callback(req, res);
          routeFound = true;
          break;
        } else {
          ReqToObject(req, res, route);
          routeFound = true;
          break;
        }
      }
    }
    return routeFound;
  }
449237
function resolvePromise(promise, state, value) {
        var onceWrapper = once();
        if (promise === value) {
            throw new TypeError('Promise resolved with itself');
        }
        if (promise[symbolState] === UNRESOLVED) {
            // should only get value.then once based on promise spec.
            var then = null;
            try {
                if (typeof value === 'object' || typeof value === 'function') {
                    then = value && value.then;
                }
            }
            catch (err) {
                onceWrapper(function () {
                    resolvePromise(promise, false, err);
                })();
                return promise;
            }
            // if (value instanceof ZoneAwarePromise) {
            if (state !== REJECTED && value instanceof ZoneAwarePromise &&
                value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) &&
                value[symbolState] !== UNRESOLVED) {
                clearRejectedNoCatch(value);
                resolvePromise(promise, value[symbolState], value[symbolValue]);
            }
            else if (state !== REJECTED && typeof then === 'function') {
                try {
                    then.apply(value, [
                        onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))
                    ]);
                }
                catch (err) {
                    onceWrapper(function () {
                        resolvePromise(promise, false, err);
                    })();
                }
            }
            else {
                promise[symbolState] = state;
                var queue = promise[symbolValue];
                promise[symbolValue] = value;
                // record task information in value when error occurs, so we can
                // do some additional work such as render longStackTrace
                if (state === REJECTED && value instanceof Error) {
                    value[__symbol__('currentTask')] = Zone.currentTask;
                }
                for (var i = 0; i < queue.length;) {
                    scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]);
                }
                if (queue.length == 0 && state == REJECTED) {
                    promise[symbolState] = REJECTED_NO_CATCH;
                    try {
                        throw new Error('Uncaught (in promise): ' + value +
                            (value && value.stack ? '\n' + value.stack : ''));
                    }
                    catch (err) {
                        var error_1 = err;
                        error_1.rejection = value;
                        error_1.promise = promise;
                        error_1.zone = Zone.current;
                        error_1.task = Zone.currentTask;
                        _uncaughtPromiseErrors.push(error_1);
                        api.scheduleMicroTask(); // to make sure that it is running
                    }
                }
            }
        }
        // Resolving an already resolved promise is a noop.
        return promise;
    }
932420
function ( x ) {

		if ( Util.is.Error( x ) ) {
			return this.reject( x );
		}

		// Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
		try {

			if ( x === this ) {
				throw new TypeError('A promise cannot be resolved with itself.');
			}

			if ( Util.is.Promise( x ) || ( x !== null && Util.is.Object( x ) && Util.is.Function( x.then ) ) ) {
				Promise.doResolve( x.then.bind( x ), this.resolve, this.reject );
				return this;
			}

			if ( Util.is.Function( x ) ) {
				Promise.doResolve( x, this.resolve, this.reject );
				return this;
			}

			this.fulfill( x );

		} catch ( error ) {

			return this.reject( error );

		}

		return this;
	}
830266
function matchRoutes(routes, path, query) {
  query = query === undefined ? {} : isString(query) ? qs.parse(query) : query;
  return matchRoutesImpl(routes, path, query);
}
8402
function resolveURL(url, path) {
  if (typeof url !== 'string' || typeof path !== 'string') {
    return new Error('url-and-path-required');
  }

  /* Remove leading and duplicate slashes */
  url = url.replace(/\/{2,}/g, '/').replace(/^\//, '').replace(':/','://');

  let parsedUrl = urlModule.parse(url);
  if (protocols.indexOf(parsedUrl.protocol) < 0 || !parsedUrl.host) {
    return new Error('invalid-url');
  }

  let resolvedUrl = urlModule.resolve(parsedUrl.href, path);
  return resolvedUrl;
}
266093
function resolveRequest({ requestKey, res, err }) {
  const handlers = requests[requestKey] || [];

  handlers.forEach(handler => {
    if (res) {
      handler.resolve(res);
    } else {
      handler.reject(err);
    }
  });

  // This list of handlers has been, well, handled. So we
  // clear the handlers for the next request.
  requests[requestKey] = null;
}
304604
function getRoutes(req, res) {
        var index = {
            name: about.name,
            version: about.version,
            description: about.description,
            routes: app.routes
        };
        return res.json(index);
    }