jfromaniello/express-unless

not able to get 'unless' working

beyondszine opened this issue · 1 comments

Hi there,

Can you please help me out with this code wher I am not yet able to get this working ?

(function(){
  'use strict';
  var unless = require('express-unless');
  var express = require('express');

  var app = express();

  var fun1  = function(req,res,next){
    console.log('fun1 was called');
    next();
  };
  fun1.unless=unless;

  var fun2  = function(req,res,next){
    console.log('fun2 was called');
    console.log(req.method);
    console.log(req.url);
    next();
  };

  app.use(fun1.unless({method : 'GET', 'url':'/'}));

  app.get('/', fun2,function(req, res,next) {
    console.log('root route hit');
    res.send('ok');
  });

  app.listen(process.env.PORT || 5553);


})();

I have the exact same problem, having trouble checking for cookies to force login if the user has not already done so.