adonis-framework
Advanced tools
Comparing version 1.0.6 to 1.0.7
{ | ||
"name": "adonis-framework", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Adonis framework a loosely coupled http server for adonis application, it does all the required hard work to setup a managable http server with depdendency injection in place.", | ||
@@ -21,4 +21,6 @@ "main": "index.js", | ||
"cookie": "^0.1.3", | ||
"cookie-signature": "^1.0.6", | ||
"dotenv": "^1.2.0", | ||
"eventemitter2": "^0.4.14", | ||
"keygrip": "git://github.com/crypto-utils/keygrip.git", | ||
"lodash": "^3.10.0", | ||
@@ -25,0 +27,0 @@ "mime": "^1.3.4", |
@@ -14,3 +14,3 @@ 'use strict' | ||
const helpers = require('./helpers') | ||
const cookie = require('cookie') | ||
const Cookies = require('../Cookies') | ||
const contentType = require('content-type') | ||
@@ -292,8 +292,5 @@ | ||
Request.prototype.cookies = function () { | ||
if (!this.request.headers.cookie) { | ||
return {} | ||
} | ||
return cookie.parse(this.request.headers.cookie) | ||
return Cookies.parse(this.request) | ||
} | ||
module.exports = Request |
@@ -10,4 +10,8 @@ 'use strict' | ||
const NodeRes = require('node-res') | ||
const Cookies = require('../Cookies') | ||
NodeRes.prototype._send = NodeRes.prototype.send | ||
function Response (View, Route) { | ||
/** | ||
@@ -30,3 +34,51 @@ * @function view | ||
/** | ||
* @function cookie | ||
* @description attaches cookie to response | ||
* @param {String} key | ||
* @param {*} value | ||
* @return {Object} reference to this for chaining | ||
*/ | ||
NodeRes.prototype.cookie = function (key, value, options) { | ||
if(!this._cookies){ | ||
this._cookies = {} | ||
} | ||
if(!key){ | ||
throw new Error('key is required to set cookie on request') | ||
} | ||
this._cookies[key] = {key:key,options:options,value:value} | ||
return this; | ||
} | ||
/** | ||
* @function clearCookie | ||
* @description clears cookie by setting it expired | ||
* @param {String} key | ||
* @return {Object} | ||
*/ | ||
NodeRes.prototype.clearCookie = function (key, options) { | ||
options = options || {} | ||
options.expires = new Date(1) | ||
return this.cookie(key,'',options) | ||
} | ||
/** | ||
* @function send | ||
* @description overrides actual node-res send method to | ||
* attach cookies while sending response | ||
* @param {*} value | ||
* @return {Object} | ||
*/ | ||
NodeRes.prototype.send = function (value){ | ||
if(this._cookies){ | ||
Cookies.attachObject(this.response,this._cookies) | ||
} | ||
this._send(value) | ||
return this | ||
} | ||
/** | ||
* @function route | ||
@@ -33,0 +85,0 @@ * @description redirect to a given route |
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
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
69084
51
2465
23
1
12
+ Addedcookie-signature@^1.0.6
+ Addedcookie-signature@1.2.2(transitive)