@adonisjs/request
Advanced tools
Comparing version 1.1.11 to 1.2.0
@@ -10,2 +10,3 @@ /// <reference types="node" /> | ||
private _config; | ||
private _secret?; | ||
parsedUrl: UrlWithStringQuery; | ||
@@ -18,6 +19,8 @@ private _body; | ||
private _lazyAccepts; | ||
private _parsedCookies; | ||
protected static _macros: {}; | ||
protected static _getters: {}; | ||
constructor(request: IncomingMessage, response: ServerResponse, _config: RequestConfig); | ||
constructor(request: IncomingMessage, response: ServerResponse, _config: RequestConfig, _secret?: string | undefined); | ||
private _parseQueryString; | ||
private _parseCookies; | ||
private _initiateAccepts; | ||
@@ -74,2 +77,10 @@ setInitialBody(body: any): void; | ||
stale(): boolean; | ||
cookies(): { | ||
[key: string]: any; | ||
}; | ||
cookie(key: string, defaultValue?: string): any; | ||
plainCookies(): { | ||
[key: string]: any; | ||
}; | ||
plainCookie(key: string, defaultValue?: string): any; | ||
} |
@@ -13,4 +13,5 @@ "use strict"; | ||
const macroable_1 = require("macroable"); | ||
const cookie_1 = require("@adonisjs/cookie"); | ||
class Request extends macroable_1.Macroable { | ||
constructor(request, response, _config) { | ||
constructor(request, response, _config, _secret) { | ||
super(); | ||
@@ -20,2 +21,3 @@ this.request = request; | ||
this._config = _config; | ||
this._secret = _secret; | ||
this.parsedUrl = url_1.parse(this.request.url, false); | ||
@@ -28,2 +30,3 @@ this._body = {}; | ||
this._lazyAccepts = null; | ||
this._parsedCookies = null; | ||
this._parseQueryString(); | ||
@@ -37,2 +40,7 @@ } | ||
} | ||
_parseCookies() { | ||
if (!this._parsedCookies) { | ||
this._parsedCookies = cookie_1.parse(this.header('cookie'), this._secret); | ||
} | ||
} | ||
_initiateAccepts() { | ||
@@ -218,2 +226,18 @@ this._lazyAccepts = this._lazyAccepts || accepts(this.request); | ||
} | ||
cookies() { | ||
this._parseCookies(); | ||
return this._parsedCookies.signedCookies; | ||
} | ||
cookie(key, defaultValue) { | ||
this._parseCookies(); | ||
return getValue(this._parsedCookies.signedCookies, key, { default: defaultValue }); | ||
} | ||
plainCookies() { | ||
this._parseCookies(); | ||
return this._parsedCookies.plainCookies; | ||
} | ||
plainCookie(key, defaultValue) { | ||
this._parseCookies(); | ||
return getValue(this._parsedCookies.plainCookies, key, { default: defaultValue }); | ||
} | ||
} | ||
@@ -220,0 +244,0 @@ Request._macros = {}; |
@@ -59,2 +59,10 @@ /// <reference types="node" /> | ||
stale(): boolean; | ||
cookies(): { | ||
[key: string]: any; | ||
}; | ||
plainCookies(): { | ||
[key: string]: any; | ||
}; | ||
cookie(key: string, defaultValue?: any): any; | ||
plainCookie(key: string, defaultValue?: any): any; | ||
} | ||
@@ -61,0 +69,0 @@ export declare type RequestConfig = { |
@@ -6,2 +6,13 @@ # Change Log | ||
# [1.2.0](https://github.com/adonisjs/adonis-framework/tree/master/packages/request/compare/@adonisjs/request@1.1.11...@adonisjs/request@1.2.0) (2019-04-24) | ||
### Features | ||
* **request:** add support for reading cookies ([adea0cd](https://github.com/adonisjs/adonis-framework/tree/master/packages/request/commit/adea0cd)) | ||
## [1.1.11](https://github.com/adonisjs/adonis-framework/tree/master/packages/request/compare/@adonisjs/request@1.1.10...@adonisjs/request@1.1.11) (2019-04-03) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@adonisjs/request", | ||
"version": "1.1.11", | ||
"version": "1.2.0", | ||
"description": "Facade over Node.js HTTP req object", | ||
@@ -38,2 +38,3 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@adonisjs/cookie": "^1.1.0", | ||
"accepts": "^1.3.5", | ||
@@ -60,3 +61,3 @@ "fresh": "^0.5.2", | ||
}, | ||
"gitHead": "38352039d052fab9592c7ebc8b818d89d68c5e7e" | ||
"gitHead": "055dcc5e2de35065bcc9a7b96ec80ec852e4909a" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18987
422
9
+ Added@adonisjs/cookie@^1.1.0
+ Added@adonisjs/cookie@1.1.0(transitive)
+ Addedcookie@0.3.1(transitive)
+ Addedcookie-signature@1.2.2(transitive)