Does any one Has every configure nack for the Rails Projects I happen to tried the dummy code
var http = require('http');
var nack = require('nack');
var app = nack.createProcess("/home/viren/myapp/config.ru");
http.createServer(function (req, res) { app.proxy(req, res); }).listen(8124, "127.0.0.1");
but it reported me with the following error
events.js:94
throw new Error(‘addListener only takes instances of Function’);
^ Error: addListener only takes instances of Function
at BufferedRequest. (events.js:94:11)
at Process. (/home/viren/node_modules/nack/lib/process.js:257:21)
at Process.proxy (/home/viren/node_modules/nack/lib/process.js:3:63)
at Server. (/home/viren/simple.proxy.js:7:7)
at Server.emit (events.js:67:17)
at HTTPParser.onIncoming (http.js:1124:12)
at HTTPParser.onHeadersComplete (http.js:108:31)
at Socket.ondata (http.js:1019:22)
at Socket._onReadable (net.js:683:27)
at IOWatcher.onReadable [as callback] (net.js:177:10)
here is my custom rack-file
require "config/environment"
use Rails::Rack::LogTailer
use ActionDispatch::Static
run ActionController::Dispatcher.new
According the source at node_modules/nack/lib/process.js:257 nack is expecting app.proxy to have a signature of app.proxy(req, res, next) with is a common idiom with connect apps. In connect, calling next(“some value”) is a convention as most apps have a catch all error handler at the bottom of the middleware chain. Since your not using connect, just create your own error handler.
I also created a pull request, so hopefully using next will be optional in the future. https://github.com/josh/nack/pull/25