{"id":14969907,"url":"https://github.com/scalajs-io/nodejs","last_synced_at":"2025-07-22T04:05:07.149Z","repository":{"id":57720949,"uuid":"55820680","full_name":"scalajs-io/nodejs","owner":"scalajs-io","description":"This project provides Scala.js type-safe bindings for Node.js (current) v8.7.0 and LTS v6.11.4  APIs. The platform supports MEAN (MongoDB, Express, AngularJs, NodeJS), Cassandra, MySQL and many other npm projects.","archived":false,"fork":false,"pushed_at":"2023-05-20T00:10:23.000Z","size":2825,"stargazers_count":163,"open_issues_count":5,"forks_count":27,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-06-25T09:43:52.270Z","etag":null,"topics":["angular","mean-stack","mongodb","mongoose","node","nodejs","npm","scala","scala-bindings","scalajs"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scalajs-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-04-09T01:52:17.000Z","updated_at":"2024-11-30T05:32:41.000Z","dependencies_parsed_at":"2025-05-08T21:12:32.029Z","dependency_job_id":"485daa4f-0e98-43f4-9b94-9e04e338ca51","html_url":"https://github.com/scalajs-io/nodejs","commit_stats":null,"previous_names":["ldaniels528/scalajs-nodejs","scalajs-io/scalajs.io","ldaniels528/scalajs-node-npm"],"tags_count":49,"template":false,"template_full_name":null,"purl":"pkg:github/scalajs-io/nodejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalajs-io%2Fnodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalajs-io%2Fnodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalajs-io%2Fnodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalajs-io%2Fnodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scalajs-io","download_url":"https://codeload.github.com/scalajs-io/nodejs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalajs-io%2Fnodejs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266424026,"owners_count":23926124,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["angular","mean-stack","mongodb","mongoose","node","nodejs","npm","scala","scala-bindings","scalajs"],"created_at":"2024-09-24T13:42:40.062Z","updated_at":"2025-07-22T04:05:07.115Z","avatar_url":"https://github.com/scalajs-io.png","language":"Scala","readme":"NodeJS (current \u0026 LTS)\n======================\nThis is a complete Scala.js facade for Node.js and npm packages; which means you can develop full-blown Node.js \napplications using popular JavaScript software stacks including the MEAN Stack ([MongoDB](https://github.com/scalajs-io/mongodb), \n[Express](https://github.com/scalajs-io/express), [Angular](https://github.com/scalajs-io/angular), Node),\n[Cassandra](https://github.com/scalajs-io/cassandra-driver), [MySQL](https://github.com/scalajs-io/mysql) \nand many other popular [npm packages](https://github.com/scalajs-io/scalajs.io-platform).\n \n## Table of Contents\n\n* \u003ca href=\"#introduction\"\u003eIntroduction\u003c/a\u003e\n* \u003ca href=\"#development\"\u003eDevelopment\u003c/a\u003e\n    * \u003ca href=\"#build_requirements\"\u003eBuild Requirements\u003c/a\u003e\n    * \u003ca href=\"#building_sdk\"\u003eBuilding the SDK\u003c/a\u003e\n    * \u003ca href=\"#resolvers\"\u003eResolvers\u003c/a\u003e\n    * \u003ca href=\"#apps_using_means\"\u003eDeveloped using ScalaJs.io\u003c/a\u003e\n    * \u003ca href=\"#discussions\"\u003eDiscussions\u003c/a\u003e\n    * \u003ca href=\"#advantages\"\u003eAdvantages over JavaScript\u003c/a\u003e\n* \u003ca href=\"#NodeJS\"\u003eNode.js bindings\u003c/a\u003e\n    * \u003ca href=\"#node_modules\"\u003eModules\u003c/a\u003e\n    * \u003ca href=\"#npm_modules\"\u003eThird-party Modules\u003c/a\u003e\n    * \u003ca href=\"#node_integration\"\u003eIntegration Guidance\u003c/a\u003e    \n* \u003ca href=\"#Express\"\u003eExpress.js bindings\u003c/a\u003e\n* \u003ca href=\"#MongoDB\"\u003eMongoDB bindings\u003c/a\u003e\n* \u003ca href=\"#Angular\"\u003eAngular.js bindings\u003c/a\u003e   \n    * \u003ca href=\"#Refinements\"\u003eScala.js Refinements\u003c/a\u003e \n    * \u003ca href=\"#social_networks\"\u003eSocial Network bindings\u003c/a\u003e \n\n\u003ca name=\"introduction\"\u003e\u003c/a\u003e\n## Introduction\n\nThe goal of this project is to provide a complete Scala.js binding for the entire MEAN Stack. Why? Because I love NodeJS,\n but I have a love/hate relationship with JavaScript. And many others feel the same way about JavaScript, which is why\n there are so many languages that are designed to improve the experience (CoffeeScript, TypeScript, Scala.js and others). \n Simply put, ScalaJs.io let's me have my cake and eat it too! And as such, I've gone to great lengths to bring all the \n things you love about developing applications on the MEAN Stack to Scala.\n \nScalaJs.io is a componentized platform; allowing developers to use only the features they want. If all your application \nrequires is a binding for AngularJS, you can use just that. Alternatively, you could use only the Node bindings, or the \nentire MEAN stack (or any of the bundled npm library bindings).\n\nCurrently, there are at least four development use cases for ScalaJs.io:\n \n* Building full MEAN stack applications using the bundled MongoDB, Express, Angular and Node bindings.\n* Building rich thin-client web front-ends using AngularJS bindings only (with any backend).\n* Building REST services using Node (and optionally Express) bindings only.\n* Building CLI applications using Node bindings only.\n\n\u003ca name=\"development\"\u003e\u003c/a\u003e\n## Development\n\n\u003ca name=\"build_requirements\"\u003e\u003c/a\u003e\n### Build Requirements\n\n* [SBT 0.13.16] (http://www.scala-sbt.org/download.html)\n\n\u003ca name=\"building_sdk\"\u003e\u003c/a\u003e\n#### Build/publish the SDK\n\n```bash\n $ sbt clean publish-local\n```\n\n\u003ca name=\"resolvers\"\u003e\u003c/a\u003e\n#### Resolvers\n\nTo add the ScalaJs.io bindings/library to your project, add the following to your build.sbt:  \n\n```   \nresolvers += Resolver.sonatypeRepo(\"releases\") \n```\n\n\u003ca name=\"apps_using_means\"\u003e\u003c/a\u003e\n### Developed using  ScalaJs.io\n   \nThe following applications were developed using ScalaJs.io:\n\n| Application                                                           | Frontend              | Backend            | Scalajs.io version | Description                              |\n|-----------------------------------------------------------------------|-----------------------|--------------------|--------------------|------------------------------------------|\n| [Phaser-Invaders](https://github.com/scalajs-io/phaser-invaders-demo) | Scala.js + DOM        | Scala + NodeJS     | 0.3.x              | Port of Phaser Invaders. |\n| [Socialize](https://github.com/scalajs-io/scalajs-nodejs-socialized)  | Scala.js + AngularJS  | Scala.js + NodeJS  | 0.4.0              | A Facebook-inspired Social networking web application. |\n| [Todo MVC](https://github.com/scalajs-io/scalajs-nodejs-todomvc)      | Scala.js + AngularJS  | Scala.js + NodeJS  | 0.2.x              | A simple Todo example application. |\n| [Trifecta](https://github.com/scalajs-io/trifecta)                    | Scala.js + AngularJS  | Scala + Play 2.4.x | 0.4.0              | Trifecta is a web-based and CLI tool that simplifies inspecting Kafka messages and Zookeeper data. |\n\n### The MEAN Stack \u0026#8212; AngularJS, MongoDB, Mongoose, Express and more\n\n| Module / Package                                                                      | Version | Description                                             |\n|---------------------------------------------------------------------------------------|---------|---------------------------------------------------------|\n| [angular](https://github.com/scalajs-io/angular)                                      | 1.6.3   | AngularJS/core binding for Scala.js |\n| [angular-anchor-scroll](https://github.com/scalajs-io/angular-anchor-scroll)          | 1.6.3   | AngularJS/anchorScroll binding for Scala.js |\n| [angular-animate](https://github.com/scalajs-io/angular-animate)                      | 1.6.3   | AngularJS/animate binding for Scala.js |\n| [angular-cookies](https://github.com/scalajs-io/angular-cookies)                      | 1.6.3   | AngularJS/cookies binding for Scala.js |\n| [angular-facebook](https://github.com/scalajs-io/angular-facebook)                    | 1.6.3   | AngularJS/facebook binding for Scala.js |\n| [angular-md5](https://github.com/scalajs-io/angular-md5)                              | 1.6.3   | AngularJS/md5 binding for Scala.js |\n| [angular-file-upload](https://github.com/scalajs-io/angular-file-upload)              | 1.6.3   | AngularJS/fileupload binding for Scala.js |\n| [angular-nvd3](https://github.com/scalajs-io/angular-nvd3)                            | 1.6.3   | AngularJS/nvd3 binding for Scala.js |\n| [angular-sanitize](https://github.com/scalajs-io/angular-sanitize)                    | 1.6.3   | AngularJS/sanitize binding for Scala.js |\n| [angular-ui-bootstrap](https://github.com/scalajs-io/angular-ui-bootstrap)            | 1.6.3   | AngularJS/ui-bootstrap binding for Scala.js |\n| [angular-ui-router](https://github.com/scalajs-io/angular-ui-router)                  | 1.6.3   | AngularJS/ui-router binding for Scala.js |\n| [angularjs-toaster](https://github.com/scalajs-io/angularjs-toaster)                  | 1.6.3   | AngularJS/toaster binding for Scala.js |\n| [express](https://github.com/scalajs-io/express)                                      | 4.13.4  | Fast, unopinionated, minimalist web framework for Node.js |\n| [mongodb](https://github.com/scalajs-io/mongodb)                                      | 2.2.22  | The official MongoDB driver for Node.js. |\n| [mongoose](https://github.com/scalajs-io/mongoose)                                    | 4.8.1   | Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. |\n| [mpromise](https://github.com/scalajs-io/mpromise)                                    | 0.5.5   | A promises/A+ conformant implementation, written for mongoose. |\n \nLooking for a complete list of available bindings? Go [here](https://github.com/scalajs-io/scalajs-io-platform)  \n \n\u003ca name=\"discussions\"\u003e\u003c/a\u003e\n### Discussions\n \nThere's a discussion about [ScalaJs.io on Reddit](https://www.reddit.com/r/scala/comments/4loosi/meansjs_scalajs_facades_for_the_nodejs_api/).    \n\n\u003ca name=\"advantages\"\u003e\u003c/a\u003e\n### Advantages over JavaScript\n\nScala.js offers many advantages over native JavaScript:\n\n* Scala.js is strongly-typed\n* Excellent IDE support\n* No JavaScript Warts\n* More concise\n* [Go beyond JavaScript ES6, today](http://www.scala-js.org)\n\nConsider the following example in JavaScript. Here we have a nested collection of callbacks (read: pyramid of doom) \nin order to gather the information that we display at the end.\n\n##### JavaScript and Node.js\n\n```javascript\nvar output1 = null;\nvar output2 = null;\nvar output3 = null;\n\nfs.mkdirp(\"/a/test/dir\", function (err1) {\n    Assert.ifError(err1);\n\n    fs.writeFile(\"/a/test/dir/file.txt\", \"Hello World\", function (err2) {\n        Assert.ifError(err2);\n\n        fs.readFile(\"/a/test/dir/file.txt\", function (err3, data) {\n            Assert.ifError(err3);\n            output1 = data; // ~\u003e Buffer(\"Hello World\")\n\n            fs.unlink(\"/a/test/dir/file.txt\", function (err4) {\n                Assert.ifError(err4);\n\n                fs.readdir(\"/a/test\", function (err5, dir) {\n                    Assert.ifError(err5);\n                    output2 = dir; // ~\u003e [\"dir\"]\n\n                    fs.stat(\"/a/test/dir\", function (err6, stats) {\n                        Assert.ifError(err6);\n                        output3 = stats.isDirectory(); // ~\u003e true\n\n                        fs.rmdir(\"/a/test/dir\", function (err7) {\n                            Assert.ifError(err7);\n                            fs.mkdirp(\"C:\\\\use\\\\windows\\\\style\\\\paths\", function (err8) {\n                                Assert.ifError(err8);\n                                \n                                console.log(\"output1 =\", output1.toString(), output1);\n                                console.log(\"output2 =\", output2);\n                                console.log(\"output3 =\", output3)\n                            })\n                        })\n                    })\n                })\n            })\n        })\n    })\n});\n```\n\nNow consider the equivalent logic in Scala.js using its much more elegant `for` comprehension:\n\n##### Scala.js and Node.js\n\n```scala\nimport io.scalajs.nodejs.console\nimport io.scalajs.nodejs.Fs._\n  \nfor {\n  _ \u003c- Fs.mkdirpFuture(\"/a/test/dir\")\n  _ \u003c- Fs.writeFileFuture(\"/a/test/dir/file.txt\", \"Hello World\")\n  output1 \u003c- Fs.readFileFuture(\"/a/test/dir/file.txt\") // ~\u003e Buffer(\"Hello World\")\n  _ \u003c- Fs.unlinkFuture(\"/a/test/dir/file.txt\")\n  output2 \u003c- Fs.readdirFuture(\"/a/test\") // ~\u003e [\"dir\"]\n  output3 \u003c- Fs.statFuture(\"/a/test/dir\").map(_.isDirectory()) // ~\u003e true\n  _ \u003c- Fs.rmdirFuture(\"/a/test/dir\")\n  _ \u003c- Fs.mkdirpFuture(\"C:\\\\use\\\\windows\\\\style\\\\paths\")\n} {\n  console.log(\"output1 =\", output1.toString(), output1)\n  console.log(\"output2 =\", output2)\n  console.log(\"output3 =\", output3)\n}\n```\n\n\u003ca name=\"NodeJS\"\u003e\u003c/a\u003e\n## Node.js\n\nThe Node.js integration is nearly complete (feature for feature), and should be more than sufficient for most web-based \nand CLI applications. Additionally, there are a growing number of third-party (mostly OSS) modules that have been \nimplemented as well, including bcrypt, cassandra-driver, kafka-node, mysql, xml2js and many others. \n\n\u003ca name=\"node_modules\"\u003e\n#### Modules\n\nThe following core Node.js modules (v8.7.0) have been implemented:\n\n| Node Module           | Description                                                                     |\n|-----------------------|---------------------------------------------------------------------------------|\n| assert                | Provides a simple set of assertion tests that can be used to test invariants. |\n| buffer                | The Buffer class was introduced as part of the Node.js API to make it possible to interact with octet streams in the context of things like TCP streams and file system operations. |\n| child_process         | The child_process module provides the ability to spawn child processes. |\n| cluster               | The cluster module allows you to easily create child processes that all share server ports. |\n| crypto                | The crypto module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign and verify functions.|\n| dns                   | Support for DNS queries. | \n| events                | Node.js Events Interface | \n| fs                    | File I/O is provided by simple wrappers around standard POSIX functions. |\n| http                  | Node.js HTTP Interface |\n| https                 | Node.js HTTPS Interface |\n| net                   | The net module provides you with an asynchronous network wrapper. |\n| os                    | Provides a few basic operating-system related utility functions. |\n| path                  | This module contains utilities for handling and transforming file paths. |\n| querystring           | The querystring module provides utilities for parsing and formatting URL query strings. |\n| readline              | Readline allows reading of a stream on a line-by-line basis. |\n| repl                  | The REPL provides a way to interactively run JavaScript and see the results. | \n| stream                | A stream is an abstract interface implemented by various objects in Node.js. | \n| string-decoder        | The string_decoder module provides an API for decoding Buffer objects into strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16 characters. |\n| timers                | The timer module exposes a global API for scheduling functions to be called at some future period of time. |\n| tty                   | The tty module provides the tty.ReadStream and tty.WriteStream classes. |\n| url                   | The url module provides utilities for URL resolution and parsing. |\n| util                  | The util module is primarily designed to support the needs of Node.js's internal APIs.|\n| vm                    | The vm module provides APIs for compiling and running code within V8 Virtual Machine contexts.|\n| zlib                  | This provides bindings to Gzip/Gunzip, Deflate/Inflate, and DeflateRaw/InflateRaw classes. |\n\n**NOTE**: The SBT artifacts for Node.js platform are (choose one): \n* NodeJS v8.7.0: \"io.scalajs\" %%% \"nodejs\" % \"0.5.0\" \n* NodeJS LTS v6.11.4: \"io.scalajs\" %%% \"nodejs-lts\" % \"0.5.0\" \n\n\u003ca name=\"npm_modules\"\u003e\n#### Third-party Modules\n\nThe following Third Party/OSS Node.js (npm) modules have been implemented:\n\n| Module / Package                                                                      | Version | Description                                             |\n|---------------------------------------------------------------------------------------|---------|---------------------------------------------------------|\n| [async](https://github.com/scalajs-io/async)                                          | 2.0.0   | Higher-order functions and common patterns for asynchronous code. |\n| [bcrypt](https://github.com/scalajs-io/bcrypt)                                        | 0.0.3   | A native JS bcrypt library for NodeJS. |\n| [bignum](https://github.com/scalajs-io/bignum)                                        | 0.12.5  | Arbitrary-precision integer arithmetic using OpenSSL. |\n| [body-parser](https://github.com/scalajs-io/body-parser)                              | 1.15.1  | Body parsing middleware. |\n| [brake](https://github.com/scalajs-io/brake)                                          | 1.0.1   | Throttle a stream with backpressure. |\n| [buffermaker](https://github.com/scalajs-io/buffermaker)                              | 1.2.0   | buffermaker is a convenient way of creating binary strings. |\n| [cassandra-driver](https://github.com/scalajs-io/cassandra-driver)                    | 3.0.2   | DataStax Node.js Driver for Apache Cassandra |\n| [cheerio](https://github.com/scalajs-io/cheerio)                                      | 0.22.0  | Tiny, fast, and elegant implementation of core jQuery designed specifically for the server |\n| [chalk](https://github.com/scalajs-io/chalk)                                          | 1.1.3   | Terminal string styling done right. Much color. |\n| [cookie](https://github.com/scalajs-io/cookie)                                        | 0.3.1   | HTTP server cookie parsing and serialization |\n| [cookie-parser](https://github.com/scalajs-io/cookie-parser)                          | 1.4.3   | Cookie parsing with signatures |\n| [colors](https://github.com/scalajs-io/colors)                                        | 1.1.2   | Get colors in your node.js console.|\n| [csv-parse](https://github.com/scalajs-io/csv-parse)                                  | 1.1.2   | CSV parsing implementing the Node.js 'stream.Transform' API.|\n| [csvtojson](https://github.com/scalajs-io/csvtojson)                                  | 1.1.4   | A tool concentrating on converting csv data to JSON with customised parser supporting.|\n| [drama](https://github.com/scalajs-io/drama)                                          | 0.1.3   | drama is an Actor model implementation for JavaScript and Node.js |\n| [escape-html](https://github.com/scalajs-io/escape-html)                              | 1.0.3   | Escape string for use in HTML |\n| [express](https://github.com/scalajs-io/express)                                      | 4.13.4  | Fast, unopinionated, minimalist web framework for Node.js |\n| [express-csv](https://github.com/scalajs-io/express-csv)                              | 0.6.0   | `express-csv` provides response csv easily to express. |\n| [express-fileupload](https://github.com/scalajs-io/express-fileupload)                | 0.0.5   | Simple express file upload middleware that wraps around connect-busboy |\n| [express-ws](https://github.com/scalajs-io/express-ws)                                | 2.0.0   | WebSocket endpoints for Express applications |\n| [feedparser-promised](https://github.com/scalajs-io/feedparser-promised)              | 1.1.1   | Wrapper around feedparser with promises. |\n| [filed](https://github.com/scalajs-io/filed)                                          | 0.1.0   | Simplified file library. |\n| [github-api-node](https://github.com/scalajs-io/github-api-node)                      | 0.11.2  | A higher-level wrapper around the Github API. |\n| [glob](https://github.com/scalajs-io/glob)                                            | 7.1.1   | A little globber. |\n| [html-to-json](https://github.com/scalajs-io/html-to-json)                            | 0.6.0   | Parses HTML strings into objects using flexible, composable filters. |\n| [htmlparser2](https://github.com/scalajs-io/htmlparser2)                              | 3.9.1   | A forgiving HTML/XML/RSS parser. The parser can handle streams and provides a callback interface. |\n| [jsdom](https://github.com/scalajs-io/jsdom)                                          | 9.9.1   | A JavaScript implementation of the WHATWG DOM and HTML standards, for use with Node.js |\n| [jwt-simple](https://github.com/scalajs-io/jwt-simple)                                | 0.5.0   | JWT(JSON Web Token) encode and decode module |\n| [kafka-node](https://github.com/scalajs-io/kafka-node)                                | 0.0.11  | A node binding for librdkafka | Tesing required |\n| [kafka-rest](https://github.com/scalajs-io/kafka-rest)                                | 0.0.4   | REST Proxy wrapper library for Kafka | Tesing required |\n| [md5](https://github.com/scalajs-io/md5)                                              | 2.1.0   | A JavaScript function for hashing messages with MD5. |\n| [memory-fs](https://github.com/scalajs-io/memory-fs)                                  | 0.3.0   | A simple in-memory filesystem. Holds data in a javascript object. |\n| [mkdirp](https://github.com/scalajs-io/mkdirp)                                        | 0.5.1   | Recursively mkdir, like mkdir -p. |\n| [moment](https://github.com/scalajs-io/moment)                                        | 2.17.1  | Parse, validate, manipulate, and display dates in JavaScript. |\n| [moment-timezone](https://github.com/scalajs-io/moment)                               | 0.5.11  | Parse and display dates in any timezone. |\n| [mongodb](https://github.com/scalajs-io/mongodb)                                      | 2.2.22  | The official MongoDB driver for Node.js. |\n| [mongoose](https://github.com/scalajs-io/mongoose)                                    | 4.8.1   | Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. |\n| [mpromise](https://github.com/scalajs-io/mpromise)                                    | 0.5.5   | A promises/A+ conformant implementation, written for mongoose. |\n| [multer](https://github.com/scalajs-io/multer)                                        | 1.1.0   | Multer is a node.js middleware for handling multipart/form-data. | Tesing required |\n| [mysql](https://github.com/scalajs-io/mysql)                                          | 2.10.2  | A node.js driver for mysql. |\n| [node-zookeeper-client](https://github.com/scalajs-io/node-zookeeper-client)          | 0.2.2   | A higher-level ZooKeeper client based on node-zookeeper with support for locking and master election. | Tesing required |\n| [numeral](https://github.com/scalajs-io/numeral)                                      | 2.0.4   | A javascript library for formatting and manipulating numbers. |\n| [oppressor](https://github.com/scalajs-io/oppressor)                                  | 0.0.1   | Streaming http compression response negotiator. | Tesing required |\n| [readable-stream](https://github.com/scalajs-io/readable-stream)                      | 2.2.2   | Streams3, a user-land copy of the stream library from Node.js. |\n| [request](https://github.com/scalajs-io/request)                                      | 2.72.1  | Simplified HTTP request client. |\n| [rxjs](https://github.com/scalajs-io/rxjs)                                            | 4.1.0   | The Reactive Extensions for JavaScript. |\n| [socket.io](https://github.com/scalajs-io/socket.io)                                  | 1.7.2   | Realtime application framework (Node.JS server). |\n| [socket.io-client](https://github.com/scalajs-io/socket.io-client)                    | 1.7.2   | Socket.io client. |\n| [splitargs](https://github.com/scalajs-io/splitargs)                                  | 0.0.7   | Splits strings into tokens by given separator except treating quoted part as a single token. |\n| [tingodb](https://github.com/scalajs-io/tingodb)                                      | 0.5.1   | Embedded Node.js database upward compatible with MongoDB. |\n| [tough-cookie](https://github.com/scalajs-io/tough-cookie)                            | 2.3.2   | RFC6265 Cookies and Cookie Jar for node.js. |\n| [transducers-js](https://github.com/scalajs-io/transducers-js)                        | 0.4.174 | A high performance Transducers implementation for JavaScript. |\n| [type-is](https://github.com/scalajs-io/type-is)                                      | 1.6.14  | Infer the content-type of a request. |\n| [watch](https://github.com/scalajs-io/watch)                                          | 0.18.0  | Utilities for watching file trees. |\n| [winston](https://github.com/scalajs-io/winston)                                      | 2.3.1   | A multi-transport async logging library for Node.js. |\n| [winston-daily-rotate-file](https://github.com/scalajs-io/winston-daily-rotate-file)  | 1.4.4   | A multi-transport async logging library for Node.js. |    \n| [xml2js](https://github.com/scalajs-io/xml2js)                                        | 0.4.16  | Simple XML to JavaScript object converter. |\n\n*NOTE*: The full SBT artifact expression is: \"io.scalajs.npm\" %%% \"xxxx\" % version (e.g. \"io.scalajs.npm\" %%% \"express\" % \"0.5.0\")\n\nI've provided an example to demonstrate how similar the Scala.js code is to the JavaScript\nthat it replaces.\n\nThe following is a simple Hello World app in Node using JavaScript:\n\n```javascript\nvar http = require(\"http\");\nhttp.createServer(function(request, response) {\n    response.writeHead(200, {\"Content-Type\": \"text/plain\"});\n    response.write(\"Hello World\");\n    response.end();\n}).listen(8888);\n```\n\nHere's the same example using Scala.js:\n\n```scala\nimport io.scalajs.nodejs.http._\nimport scalajs.js\n\nHttp.createServer((request: ClientRequest, response: ServerResponse) =\u003e {\n    response.writeHead(200, js.Dictionary(\"Content-Type\" -\u003e \"text/plain\"))\n    response.write(\"Hello World\")\n    response.end()\n}).listen(8888)\n```\n\n\u003ca name=\"Express\"\u003e\u003c/a\u003e\n## Express.js\n\nThe following is a simple Hello World app in Node and Express using JavaScript:\n\n```javascript\nvar express = require('express');\nvar app = express();\n\napp.get('/', function (req, res) {\n   res.send('Hello World');\n})\n\nvar server = app.listen(8081, function () {\n  var host = server.address().address\n  var port = server.address().port\n  console.log(\"Example app listening at http://%s:%s\", host, port)\n})\n```\n\nHere's the same example using Scala.js:\n\n```scala\nimport io.scalajs.nodejs.console\nimport io.scalajs.npm.express._\n\nval app = Express()\n\napp.get(\"/\", (req: Request, res: Response) =\u003e res.send(\"Hello World\"))\n\nval server = app.listen(8081, connect)\n\nprivate def connect: js.Function = () =\u003e {\n    val host = server.address().address\n    val port = server.address().port\n    console.log(\"Example app listening at http://%s:%s\", host, port)\n}\n```\n\nThe following is a more elaborate example:\n\n```scala\nimport io.scalajs.npm.express._\nimport io.scalajs.util.ScalaJsHelpers._\nimport scalajs.js\n\nval todos: js.Array[Todo] = emptyArray\n\nval app = Express()\n\napp.use(BodyParser.json())\napp.use(BodyParser.urlencoded(new UrlEncodedBodyOptions(extended = true)))   \n \napp.get(\"/api/todo/:id\", (request: Request, response: Response) =\u003e getTodo(request, response))\napp.get(\"/api/todos\", (request: Request, response: Response) =\u003e getTodos(request, response))\napp.post(\"/api/todo\", (request: Request, response: Response) =\u003e createTodo(request, response))\n\ndef createTodo(request: Request, response: Response) = {\n    request.bodyAs[Todo] match {\n        case todo if todo.hasTitle =\u003e\n            todo.id = UUID.randomUUID().toString\n            todos.push(todo)\n            response.send(todos)\n        case todo =\u003e\n            response.badRequest(todo)\n    }\n}\n  \ndef getTodo(request: Request, response: Response) = {\n    val todoId = request.params(\"id\")\n    todos.indexWhereOpt(_.id == todoId) match {\n        case Some(index) =\u003e response.send(todos(index))\n        case None =\u003e response.notFound(todoId)\n    }\n}\n\ndef getTodos(request: Request, response: Response) = response.send(todos)\n\n@js.native\ntrait Todo extends js.Object {\n    var id: String = js.native\n    var title: String = js.native\n    var completed: Boolean = js.native\n}\n\nimplicit class TodoExtensions(val todo: Todo) extends AnyVal {\n\n    @inline\n    def hasId: Boolean = Option(todo).flatMap(t =\u003e Option(t.id)).exists(_.trim.nonEmpty)\n    \n    @inline\n    def hasTitle: Boolean = Option(todo).flatMap(t =\u003e Option(t.title)).exists(_.trim.nonEmpty)\n    \n    @inline\n    def isComplete: Boolean = hasId \u0026\u0026 hasTitle\n\n}\n```\n    \n\u003ca name=\"MongoDB\"\u003e\u003c/a\u003e\n## MongoDB\n\nThe following example demonstrates establishing a connection to MongoDB using Scala.js:\n\n```scala\nimport io.scalajs.nodejs.console\nimport io.scalajs.npm.mongodb._\nimport io.scalajs.util.ScalaJsHelper._\n\n// Connection URL. This is where your mongodb server is running.\nval url = \"mongodb://localhost:27017/test\"\n\n// Use connect method to connect to the Server\nMongoClient.connect(url, (err, db) =\u003e {\n    if (isDefined(err)) {\n        console.log(\"Unable to connect to the mongoDB server. Error:\", err)\n    } else {\n        // HURRAY!! We are connected. :)\n        console.log(\"Connection established to: %s\", url)\n        \n        // TODO do some work here with the database.\n        \n        // close connection\n        db.close()\n    }\n})\n```\n\nOr, if you'd like to be more Scala idiomatic, the connection fragment could be written as follows:\n\n```scala\nimport io.scalajs.nodejs.console\nimport io.scalajs.npm.mongodb._\nimport scala.util.{Success, Failure}\n\nMongoClient.connectFuture(url) onComplete {\n    case Success(db) =\u003e\n        // HURRAY!! We are connected. :)\n        console.log(\"Connection established to: %s\", url)\n\n        // TODO do some work here with the database.\n\n        // close connection\n        db.close()\n    case Failure(e) =\u003e\n        console.log(\"Unable to connect to the mongoDB server. Error:\", e.getMessage)  \n}\n```\n\nAlternatively, you could choose to use \"foreach\" to directly manage only the success case:\n\n```scala\nimport io.scalajs.npm.mongodb._\nimport io.scalajs.util.PromiseHelper._\n\nMongoClient.connectFuture(url) foreach { db =\u003e \n    // HURRAY!! We are connected. :)\n    console.log(\"Connection established to: %s\", url)\n\n    // TODO do some work here with the database.\n\n    // close connection\n    db.close()\n}\n```\n\nScalaJs.io exposes Future-based alternatives to most of the asynchronous functions found in MongoDB, Express, Angular and Node. \nThis means that you can use Scala's amazing *for* comprehensions to replace the dreaded pyramid of doom callbacks normally\nassociated with JavaScript asynchronous code.\n\nConsider the following:\n\n```scala\nfor {\n    // List all the virtual machine images you can use.\n    vmImages \u003c- computeManagementClient.virtualMachineVMImages.listFuture\n    \n    // Create a cloud service.\n    computeManagementClient \u003c- computeManagementClient.hostedServices.createFuture(\n      HostedServicesOptions(serviceName = serviceName, label = \"cloud service 01\", location = \"West US\"))\n    \n    // Create a virtual machine in the cloud service\n    deployment \u003c- computeManagementClient.virtualMachines.createDeploymentFuture(serviceName, deploymentOptions)\n} {\n    console.info(deployment)\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalajs-io%2Fnodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscalajs-io%2Fnodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalajs-io%2Fnodejs/lists"}