我正在使用 shrinkroute https://npmjs.org/package/shrinkroute在 nodejs 中创建链接。我收到错误 500 ReferenceError:未定义收缩器
如何将 shrinkroute 传递给 routes/index.js?有没有更好的方法通过传递查询字符串 args 来创建 url?
//app.js
var app = express();
var shrinkr = shrinkroute( app, {
"user": {
path: "/user/:id?",
get: routes.showOrListUsers
}
});
//url method works in app.js
var url = shrinkr.url( "user", { id: 5, page:40, type:'a' } );
console.log(url);
app.use( shrinkr.middleware );
//routes/index.js
exports.showOrListUsers = function(req, res, next) {
console.log(req.params);
//shrinkr errors out in index.js
var url2 = shrinkr.url( "users", {name: "foo"});
console.log(url2);
}