Nodeschool Public Materials
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    connect-testabpublic

    connect-testab

    Just a simple A/B testing middleware for connect.

    Install

    $ npm install connect-testab

    Usage

    var connect = require('connect'),
    testAB = require('connect-testab'),
    app = connect();
    app.use(connect.cookieParser());
    app.use(testAB());
    app.get('/', function(req, res){
        res.send('test ' + req.testAB);
    });
    

    See a full express example

    By default the test will be persisted on a cookie for 7 days. You can change this value by providing a new time in milisecs.

    var connect = require('connect'),
    testAB = require('connect-testab'),
    ONE_DAY = 24 * 60 * 60 * 1000;
    app = connect();
    app.use(connect.cookieParser());
    app.use(testAB(ONE_DAY));
    app.get('/', function(req, res){
        res.send('test ' + req.testAB);
    });
    

    If you do not want to persist it on a cookie just pass a -1

    var connect = require('connect'),
    testAB = require('connect-testab'),
    NO_COOKIES = -1;
    app = connect();
    app.use(connect.cookieParser());
    app.use(testAB(NO_COOKIES));
    app.get('/', function(req, res){
        res.send('test ' + req.testAB);
    });
    

    License

    MIT. See LICENSE file.

    Keywords

    none

    install

    npm i connect-testab

    Downloadslast 7 days

    3

    version

    0.0.1

    license

    none

    repository

    github.com

    last publish

    collaborators

    • avatar