I have this:
./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
I'm trying to separate url from app.coffee by defining it in another file url.coffee.
But the callback cannot receive (req, res) args, the error is:
req is not defined, but if the callback receives no args, it works fine. Anybody have any thoughts or suggestion?
Shouldn't it be something like:
var express = require "express",
helper = require "./utils/helper"
app = express();
app.get = helper.getUrl
?