结语(用于 Sequelize ORM 休息端点的 npm 模块)只有 5 个月大,因此文档很少,但我想知道如何使用它的 npm 页面上的示例中间件模块https://www.npmjs.com/package/epilogue
控制台错误读取
return context.continue;
^^^^^^
SyntaxError: Unexpected token return
我正在尝试添加中间件进行身份验证,我是 node/js 的新手,只是粘贴了示例代码开始,我不知道如何使用它。
// 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;
}
}
}
};