I obeyed, therefore I wrote an opal
NPM package.
Now I can trash Rails and opal-rails
and start working on Node only!
server = Server.new 3000 server.start do [200, {'Content-Type' => 'text/plain'}, ["Hello World!n"]] end
For it I had to write the Server
class:
class Server def initialize port @http = `require('http')` @port = port end def start &block %x{ this.http.createServer(function(req, res) { var rackResponse = (block.call(block._s, req, res)); res.end(rackResponse[2].join(' ')); }).listen(this.port); } end end
Put them in app.opal
and then start the server:
$ npm install -g opal # <<< install the NPM package first! $ opal-node app
YAY! now I can roflSCALE all of my RAils apps!!1
Cross posted from Eliæ
Leave a Reply