Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fflip

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fflip - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

4

lib/fflip-request.js
'use strict';
module.exports = FFlipRequestObject;

@@ -7,6 +6,7 @@ /**

* @param {FFlip} fflip The fflip main module
* @param {[Object]} flags A set of feature overrides, these flags will
* @param {[Object]} flags A set of feature overrides, these flags will
* take precedence over the normal feature criteria.
* @constructor
*/
module.exports = FFlipRequestObject;
function FFlipRequestObject(fflip, flags) {

@@ -13,0 +13,0 @@ this._fflip = fflip;

@@ -185,5 +185,4 @@ /**

* @return {void}
* @private
*/
_express_middleware: function(req, res, next) {
express_middleware: function(req, res, next) {

@@ -212,5 +211,4 @@ // Attach the fflip object to the request

* @return {void}
* @private
*/
_express_route: function(req, res, next) {
express_route: function(req, res, next) {
var name = req.params.name;

@@ -279,7 +277,7 @@ var action = req.params.action;

// Express Middleware
app.use(this._express_middleware);
app.use(this.express_middleware);
// Manual Flipping Route
app.get('/fflip/:name/:action', this._express_route);
app.get('/fflip/:name/:action', this.express_route);
},
};

@@ -6,3 +6,3 @@ {

"licence": "MIT",
"version": "2.0.0",
"version": "2.1.0",
"main": "lib/fflip",

@@ -9,0 +9,0 @@ "repository": "FredKSchott/fflip",

@@ -154,4 +154,10 @@ [![Build Status](https://travis-ci.org/FredKSchott/fflip.png)](https://travis-ci.org/FredKSchott/fflip)

####Low-level integration
If you need a finer-grained Express integration, such as changing the URL for manual overrides, adding security middleware, or applying middleware on a subset of routes, you can use ``express_middleware`` and ``express_route`` directly.
```
app.use(fflip.express_middleware);
app.get('/custom_path/:name/:action', fflip.express_route);
```
##Special Thanks
Original logo designed by <a href="http://thenounproject.com/Luboš Volkov" target="_blank">Luboš Volkov</a>

@@ -214,3 +214,3 @@ 'use strict';

var me = this;
fflip._express_middleware(this.reqMock, this.resMock, function() {
fflip.express_middleware(this.reqMock, this.resMock, function() {
assert(me.reqMock.fflip);

@@ -224,3 +224,3 @@ assert(me.reqMock.fflip._flags, me.reqMock.cookies.fflip);

var me = this;
fflip._express_middleware(this.reqMock, this.resMock, function() {
fflip.express_middleware(this.reqMock, this.resMock, function() {
assert.doesNotThrow(function() {

@@ -235,3 +235,3 @@ me.resMock.render('testview');

var me = this;
fflip._express_middleware(this.reqMock, this.resMock, function() {
fflip.express_middleware(this.reqMock, this.resMock, function() {
var features = {features : { fClosed: true }};

@@ -255,3 +255,3 @@ var featuresString = JSON.stringify(features);

var spy = sandbox.spy(fflip, 'userFeatures');
fflip._express_middleware(this.reqMock, this.resMock, function() {
fflip.express_middleware(this.reqMock, this.resMock, function() {
me.reqMock.fflip.setForUser(userXYZ);

@@ -267,3 +267,3 @@ assert(fflip.userFeatures.calledOnce);

var me = this;
fflip._express_middleware(this.reqMock, this.resMock, function() {
fflip.express_middleware(this.reqMock, this.resMock, function() {
me.reqMock.fflip.setForUser(userXYZ);

@@ -280,3 +280,3 @@ assert.strictEqual(me.reqMock.fflip.has('fOpen'), true);

assert.throws(function() {
fflip._express_middleware(this.reqMock, this.resMock, function() {
fflip.express_middleware(this.reqMock, this.resMock, function() {
me.reqMock.fflip.has('fOpen');

@@ -290,3 +290,3 @@ });

var consoleErrorStub = sandbox.stub(console, 'error'); // Supress Error Output
fflip._express_middleware(this.reqMock, this.resMock, function() {
fflip.express_middleware(this.reqMock, this.resMock, function() {
assert.ok(isObjectEmpty(me.reqMock.fflip.features));

@@ -300,3 +300,3 @@ done();

fflip.express(this.appMock);
assert.ok(this.appMock.use.calledWith(fflip._express_middleware));
assert.ok(this.appMock.use.calledWith(fflip.express_middleware));
});

@@ -306,3 +306,3 @@

fflip.express(this.appMock);
assert.ok(this.appMock.get.calledWith('/fflip/:name/:action', fflip._express_route));
assert.ok(this.appMock.get.calledWith('/fflip/:name/:action', fflip.express_route));
});

@@ -331,3 +331,3 @@

this.reqMock.params.name = 'doesnotexist';
fflip._express_route(this.reqMock, this.resMock, function(err) {
fflip.express_route(this.reqMock, this.resMock, function(err) {
assert(err);

@@ -343,3 +343,3 @@ assert(err.fflip);

this.reqMock.cookies = null;
fflip._express_route(this.reqMock, this.resMock, function(err) {
fflip.express_route(this.reqMock, this.resMock, function(err) {
assert(err);

@@ -353,3 +353,3 @@ assert(err.fflip);

it('should set the right cookie flags', function() {
fflip._express_route(this.reqMock, this.resMock);
fflip.express_route(this.reqMock, this.resMock);
assert(this.resMock.cookie.calledWithMatch('fflip', {fClosed: true}, { maxAge: 900000 }));

@@ -359,3 +359,3 @@ });

it('should send back 200 json response on successful call', function() {
fflip._express_route(this.reqMock, this.resMock);
fflip.express_route(this.reqMock, this.resMock);
assert(this.resMock.json.calledWith(200));

@@ -387,3 +387,3 @@ });

// it('should call res.cookie() on successful request', function() {
// self._express_route(this.reqMock, this.resMock);
// self.express_route(this.reqMock, this.resMock);
// assert(res.cookie.calledWith('fflip'));

@@ -394,2 +394,2 @@ // });

});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc