Default-http
This is just a repository to factor classes that I always use in my web projects as an abstraction for every "req" and "res" object in Restify, Koa, Hapi and Express.
/** * This is a standard HttpRequest object that aims to be used in any web server framework */ /** * This creates need a new HttpRequest * @param * @param * @param * @param * @param * @param * @param * @param * @param * @param * @param * @param */ { /** * The is the method attribute * @type */ thismethod = method /** * The is the body of the request * @type */ thisbody = body /** * The is the cookie array of the request * @type */ thiscookies = cookies /** * This is hostname * @type */ thishostname = hostname /** * The sending ip * @type */ thisip = ip /** * The request url * @type */ thisurl = url /** * The url params of the request * @type */ thisparams = params /** * The request path * @type */ thispath = path /** * The request protocol * @type */ thisprotocol = protocol /** * The query params of the request * @type */ thisquery = query /** * Is the request secure ? * @type */ thissecure = secure /** * The request headers * @type */ thisheaders = headers /** * The default request from the server * @type */ thisreq = req }
/** * This is a standard HttpResponse object that aims to be used in any web server framework */ /** * Create a new standard HttpResponse * @param * @param * @param */ { if content && !contentcontent && !contentpage throw ErrorsNO_CONTENT /** * The http code of the request * @type */ thiscode = code ? code : 200 // eslint-disable-line no-unneeded-ternary /** * Object that could have both content or page property * @type */ thiscontent = content ? content : content: Constantsthiscode // eslint-disable-line no-unneeded-ternary /** * The response headers * @type */ thisheaders = headers }