{"id":20720163,"url":"https://github.com/scalajs-io/express-ws","last_synced_at":"2026-04-09T16:02:44.415Z","repository":{"id":77422516,"uuid":"81691923","full_name":"scalajs-io/express-ws","owner":"scalajs-io","description":"WebSocket endpoints for Express applications","archived":false,"fork":false,"pushed_at":"2019-06-17T23:08:35.000Z","size":19,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-17T22:42:39.033Z","etag":null,"topics":["express","expressjs","node","nodejs","npm","npm-package","websocket"],"latest_commit_sha":null,"homepage":null,"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}},"created_at":"2017-02-12T00:14:30.000Z","updated_at":"2019-06-17T23:08:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"be938693-8441-47a2-97be-dd027e83a4a5","html_url":"https://github.com/scalajs-io/express-ws","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalajs-io%2Fexpress-ws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalajs-io%2Fexpress-ws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalajs-io%2Fexpress-ws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalajs-io%2Fexpress-ws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scalajs-io","download_url":"https://codeload.github.com/scalajs-io/express-ws/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242995884,"owners_count":20218815,"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":["express","expressjs","node","nodejs","npm","npm-package","websocket"],"created_at":"2024-11-17T03:19:31.815Z","updated_at":"2026-04-09T16:02:39.372Z","avatar_url":"https://github.com/scalajs-io.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"ExpressWS API for Scala.js\n================================\n[express-ws](https://www.npmjs.com/package/express-ws) - WebSocket endpoints for [Express](https://github.com/scalajs-io/express) applications.\n\n### Description\n\nWebSocket endpoints for [Express](https://github.com/scalajs-io/express) applications. \nLets you define WebSocket endpoints like any other type of route, \nand applies regular Express midddleware like for anything else.\n\nVersion 2.0 of this library contains a breaking change. \nPlease make sure to read [CHANGELOG.md](https://github.com/HenningM/express-ws/blob/master/CHANGELOG.md) before upgrading.\n\n### Build Dependencies\n\n* [SBT v1.2.x](http://www.scala-sbt.org/download.html)\n\n### Build/publish the SDK locally\n\n```bash\n $ sbt clean publish-local\n```\n\n### Running the tests\n\nBefore running the tests the first time, you must ensure the npm packages are installed:\n\n```bash\n$ npm install\n```\n\nThen you can run the tests:\n\n```bash\n$ sbt test\n```\n\n### Examples\n\n```scala\nimport io.scalajs.npm.express._\nimport io.scalajs.npm.expressws._\nimport io.scalajs.util.JSONHelper._\nimport io.scalajs.util.ScalaJsHelper._\nimport scala.scalajs.js\n\nval app = Express().withWsRouting\nval expressWs = ExpressWS(app)\n\napp.use((req: Request, res: Response, next: js.Function0[Unit]) =\u003e {\n    println(\"middleware\")\n    req.dynamic.testing = \"testing\"\n    next()\n})\n\napp.get(\"/\", (ws: WS, req: Request, res: Response, next: js.Function0[Unit]) =\u003e {\n    println(s\"get route ${req.dynamic.testing}\")\n    res.end()\n})\n\napp.ws(\"/\", (ws: WS, req: Request) =\u003e {\n    ws.onMessage { msg =\u003e\n      println(msg.toJson)\n    }\n    println(s\"socket: ${req.dynamic.testing}\")\n})\n\napp.listen(3000)\n ```\n\n### Artifacts and Resolvers\n\nTo add the `ExpressWS` binding to your project, add the following to your build.sbt:  \n\n```sbt\nlibraryDependencies += \"io.scalajs.npm\" %%% \"express-ws\" % \"0.5.0\"\n```\n\nOptionally, you may add the Sonatype Repository resolver:\n\n```sbt   \nresolvers += Resolver.sonatypeRepo(\"releases\") \n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalajs-io%2Fexpress-ws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscalajs-io%2Fexpress-ws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalajs-io%2Fexpress-ws/lists"}