{"id":13503843,"url":"https://github.com/opal/opal-node","last_synced_at":"2025-04-14T19:32:15.131Z","repository":{"id":3547673,"uuid":"4608119","full_name":"opal/opal-node","owner":"opal","description":"Coffescript was so cool…","archived":false,"fork":false,"pushed_at":"2014-12-20T23:09:19.000Z","size":851,"stargazers_count":88,"open_issues_count":0,"forks_count":8,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-04-23T20:54:17.763Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-09T15:15:34.000Z","updated_at":"2022-05-11T14:54:31.000Z","dependencies_parsed_at":"2022-09-06T04:40:32.988Z","dependency_job_id":null,"html_url":"https://github.com/opal/opal-node","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opal%2Fopal-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opal%2Fopal-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opal%2Fopal-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opal%2Fopal-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opal","download_url":"https://codeload.github.com/opal/opal-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248946046,"owners_count":21187437,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T23:00:46.455Z","updated_at":"2025-04-14T19:32:14.619Z","avatar_url":"https://github.com/opal.png","language":"JavaScript","readme":"\n# Opal for Node.js\n\n---\n\n\u003e **WARNING** \n\u003e \n\u003e This project is currently slightly outdated, the current preferred way to use Opal with Node.js is to compile the app and use node to run the compilation result. \n\u003e \n\u003e A `nodejs` file is now available directly [in the stdlib](https://github.com/opal/opal/blob/master/stdlib/nodejs.rb) and Node.js is also the default runner for the CLI (see `opal --help` for a list of alternative runners). An example of this can be found in [the `mspec_node` rake task](https://github.com/opal/opal/blob/master/Rakefile#L62-L63).\n\n---\n\n\n\n[![Build Status](https://secure.travis-ci.org/elia/opal-node.svg)](http://travis-ci.org/elia/opal-node)\n\nUse Ruby on Node.js for **REAL-WORLD rofl-SCALING**\n\n\u003cbr\u003e\n\u003e Use Node.js FOR SPEED\n\u003e\n\u003e — \u003ccite\u003e[@RoflscaleTips](https://twitter.com/RoflscaleTips/status/57551756657303552)\u003c/cite\u003e\n\n\n\u003cbr\u003e\n\u003e [@hipsterhacker](https://twitter.com/hipsterhacker) I approve of your choices of roflscale technologies, particularly Node. Your roflmillions of users will appreciate it.\n\u003e\n\u003e — \u003ccite\u003e[@RoflscaleTips](https://twitter.com/RoflscaleTips/status/50320781162446848)\u003c/cite\u003e\n\n\u003cbr\u003e\n\u003e mongodb should be ported to nodejs for improved scalability\n\u003e\n\u003e — \u003ccite\u003e[@RoflscaleTips](https://twitter.com/RoflscaleTips/status/190291005138939904)\u003c/cite\u003e\n\n\n\n## Usage\n\nRun with `opal-node app.rb`\nor run the repl: `opal-node-irb`\n\n\n### Installing\n\nInstall with NPM: `npm install -g opal`\nor via RVM: `rvm install opal`\n\n\n## Example ([rack](http://rack.github.io))\n\n\n```ruby\n# app.rb\nrequire 'http/server'\nHTTP::Server.start 3000 do\n  [200, {'Content-Type' =\u003e 'text/plain'}, [\"Hello World!\\n\"]]\nend\n```\n\nThis is the original Node.js example:\n\n```js\n// the original nodejs example\nhttp = require('http')\nvar port = process.env.port || 1337;\nhttp.createServer(function(req, res) {\n  res.writeHead(200, { 'Content-Type': 'text/plain' });\n  res.end('Hello World\\n');\n}).listen(port);\n```\n\n\nHere's the (naïve) rack-like implementation of `http/server.rb`\n\n```ruby\n# http/server.rb\nmodule HTTP\n  `_http = require('http')`\n  class Server \u003c `_http.Server`\n    alias_native :listen, :listen\n\n    def self.start port, \u0026block\n      server = new `function(request, response) {\n        request.on('end', function(chunk) {\n          var rackResponse = #{ block.call(`request`, `response`) };\n          response.writeHead(rackResponse[0], #{ `rackResponse[1]`.to_native });\n          response.end( rackResponse[2].join(' ') );\n        })\n      }`\n      server.listen(port)\n      server\n    end\n  end\nend\n```\n\n\n### Example 2 ([express.js](http://expressjs.com) wrapper)\n\nA simple Express.js wrapper example can be found in [`examples/express-wrapper.rb`](https://github.com/opal/opal-node/blob/master/examples/express-wrapper.rb)\n\n```ruby\nExpress.new do\n  get '/' do |req, res|\n    res.send 200, 'hulla!'\n  end\nend.listen 3000\n```\n\n\n\n## Developing\n\nStart a coffee watcher to keep opal.js in sync with opal.coffee\n\n    coffee -cwo lib/ lib/*.coffee\n\n\n### Running in development\n\n    NODE_PATH=\"$NODE_PATH:../lib/\" node ./bin/opal-node\n    NODE_PATH=\"$NODE_PATH:../lib/\" node ./bin/opal-node-irb\n\n\n## Testing\n\nTo keep the specs running while developing just install and use [spectator](https://github.com/elia/spectator#readme)\nthat will compile `opal.coffee` to `opal.js` before every run of the spec.\n\n\t$ gem install spectator\n\t$ gem install notify # to get notification\n\t$ spectator\n\t--- Waiting for changes...\n\n\n\n## License\n\nThis project rocks and uses MIT-LICENSE.\n","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopal%2Fopal-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopal%2Fopal-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopal%2Fopal-node/lists"}