express-namespace和express-resource不允许使用地图 [英] express-namespace and express-resource wont allow map
问题描述
我正在尝试为资源创建自定义地图,
I'm trying to creating a custom map for a resource,
app.namespace('/v1', function(){
var sessionResource = app.resource('session', require('./routes/v1/session'));
sessionResource.map('/test', sessionResource.index);
});
这些地图如下所示,但是如果没有自定义地图,则ns和资源会正常工作
the maps breaks as follow, however without the custom map the ns and the resource work smoothly
/home/kuryaki/piitri/newApi/node_modules/express-resource/index.js:125
if ('/' == path[0]) path = path.substr(1);
^
TypeError: Cannot read property '0' of undefined
at Resource.map (/home/kuryaki/piitri/newApi/node_modules/express-resource/index.js:125:18)
at HTTPServer.<anonymous> (/home/kuryaki/piitri/newApi/app.js:44:31)
at HTTPServer.exports.namespace (/home/kuryaki/piitri/newApi/node_modules/express-namespace/index.js:31:6)
at Object.<anonymous> (/home/kuryaki/piitri/newApi/app.js:42:5)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
存在索引方法,这就是我实际对其进行测试的方式
the index method exists thats how i actually test it
在本地主机上获取/v1/会话
GET /v1/session at localhost
我尝试使用v0.6.14,v0.8.4和v0.9.0pre节点,但是我做错了什么吗?
i have tried with node v0.6.14, v0.8.4 and v0.9.0pre and none work am i doing something wrong?
推荐答案
express-resource尚未完全表达3兼容.
express-resource is not yet fully express 3 compatible.
不过,您可以在package.json中使用它安装Express-resource的特殊分支
You can however install a special branch of express-resource using this in your package.json
"express-resource":
"git://github.com/visionmedia/express-resource.git#add/express3x-support"
或 npm从命令行安装git://github.com/visionmedia/express-resource.git#add/express3x-support
.
我已经愉快地使用了express-resource的分支一段时间了.我已经从express-resource的github问题页面上找到了这个分支.
I've been using that branch of express-resource happily for a while now. I've found out about this branch from express-resource's github issues page.
这篇关于express-namespace和express-resource不允许使用地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!