SyntaxError:意外的令牌返回

时间:2016-03-29 18:57:51

标签: javascript node.js authentication sequelize.js epilogue

Epilogue(Sequelize ORM休息端点的npm模块)只有5个月的时间,因此稀疏的文档,但我想知道如何使用它上面的示例中间件模块&nbsp;页面https://www.npmjs.com/package/epilogue < / p>

控制台错误读取

     return context.continue;
      ^^^^^^

SyntaxError: Unexpected token return

我尝试添加中间件进行身份验证,我是node / js的新手,只是粘贴了示例代码,我不确定如何使用它。< / p>

// middleware.js
module.exports = {
  create: {
    fetch: function(req, res, context) {
    // manipulate the fetch call

    console.log('Request URL:', req.originalUrl);
        next();
    }, function (req, res, next) {

        console.log('Request Type:', req.method);
        next();
    }

      return context.continue;
    }
  },
  list: {
    write: {
      before: function(req, res, context) {
        // modify data before writing list data
        return context.continue;
      },
      action: function(req, res, context) {
        // change behavior of actually writing the data
        return context.continue;
      },
      after: function(req, res, context) {
        // set some sort of flag after writing list data
        return context.continue;
      }
    }
  }
};

1 个答案:

答案 0 :(得分:0)

语法错误。

// middleware.js
module.exports = {
  create: {
    fetch: function(req, res, context) {
    // manipulate the fetch call

        console.log('Request URL:', req.originalUrl);
        console.log('Request Type:', req.method);


      return context.continue;
    }
  },
  list: {
    write: {
      before: function(req, res, context) {
        // modify data before writing list data
        return context.continue;
      },
      action: function(req, res, context) {
        // change behavior of actually writing the data
        return context.continue;
      },
      after: function(req, res, context) {
        // set some sort of flag after writing list data
        return context.continue;
      }
    }
  }
};