我有这个:
./urls.coffee
urlConfig = [
["/", (req, res) -> res.send "hello world"]
]
module.exports = urlConfig
./utils/helpers.coffee
getUrl = (app, urlconfig)->
for url in urlconfig
app.get url[0], url[1]
module.exports.getUrl = getUrl
./app.coffee
express = require "express",
app = express();
helper = require "./utils/helper"
urls = require "./urls"
helper.getUrl app, urls
我试图url
通过app.coffee
在另一个文件中定义它来区分url.coffee
。
但是回调不能接收(req, res)
参数,错误是:
req is not defined
,但是如果回调没有接收到参数,它工作正常。有人有什么想法或建议吗?