{
  "name": "express-ws",
  "version": "2.0.0-rc.1",
  "description": "WebSocket endpoints for Express applications",
  "main": "index.js",
  "scripts": {
    "prepublish": "npm run build",
    "build": "babel src/ -d lib/",
    "lint": "eslint src/"
  },
  "author": {
    "name": "Henning Morud",
    "email": "henning@morud.org"
  },
  "contributors": [
    {
      "name": "Jesús Leganés Combarro",
      "email": "piranna@gmail.com"
    },
    {
      "name": "Sven Slootweg",
      "email": "admin@cryto.net"
    },
    {
      "name": "Andrew Phillips",
      "email": "theasp@gmail.com"
    }
  ],
  "license": "BSD-2-Clause",
  "dependencies": {
    "ws": "^1.0.0"
  },
  "peerDependencies": {
    "express": "^4.0.0"
  },
  "directories": {
    "example": "examples"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/HenningM/express-ws"
  },
  "keywords": [
    "express",
    "ws",
    "websocket"
  ],
  "bugs": {
    "url": "https://github.com/HenningM/express-ws/issues"
  },
  "homepage": "https://github.com/HenningM/express-ws",
  "devDependencies": {
    "babel-cli": "^6.5.1",
    "babel-preset-es2015": "^6.5.0",
    "eslint": "^1.10.3",
    "eslint-config-airbnb": "^5.0.0"
  },
  "readme": "# express-ws [![Dependency Status](https://www.versioneye.com/nodejs/express-ws/badge?style=flat)](https://www.versioneye.com/nodejs/express-ws)\n\n[WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) endpoints for [Express](http://expressjs.com/) applications. Lets you define WebSocket endpoints like any other type of route, and applies regular Express midddleware like for anything else.\n\nVersion 2.0 of this library contains a breaking change. Please make sure to read [CHANGELOG.md](CHANGELOG.md) before upgrading.\n\n## Installation\n\n`npm install --save express-ws`\n\n## Usage\n\n__Full documentation can be found in the API section below. This section only shows a brief example.__\n\nAdd this line to your Express application:\n\n```javascript\nvar expressWs = require('express-ws')(app);\n```\n\nNow you will be able to add WebSocket routes (almost) the same way you add other routes. The following snippet sets up a simple echo server at `/echo`.\n\n```javascript\napp.ws('/echo', function(ws, req) {\n  ws.on('message', function(msg) {\n    ws.send(msg);\n  });\n});\n```\n\nIt works with routers, too, this time at `/ws-stuff/echo`:\n\n```javascript\nvar router = express.Router();\n\nrouter.ws('/echo', function(ws, req) {\n  ws.on('message', function(msg) {\n    ws.send(msg);\n  });\n});\n\napp.use(\"/ws-stuff\", router);\n```\n\n## Full example\n\n```javascript\nvar express = require('express');\nvar app = express();\nvar expressWs = require('express-ws')(app);\n\napp.use(function (req, res, next) {\n  console.log('middleware');\n  req.testing = 'testing';\n  return next();\n});\n\napp.get('/', function(req, res, next){\n  console.log('get route', req.testing);\n  res.end();\n});\n\napp.ws('/', function(ws, req) {\n  ws.on('message', function(msg) {\n    console.log(msg);\n  });\n  console.log('socket', req.testing);\n});\n\napp.listen(3000);\n```\n\n## API\n\n### expressWs(app, *server*, *options*)\n\nSets up `express-ws` on the specified `app`. This will modify the global Router prototype for Express as well - see the `leaveRouterUntouched` option for more information on disabling this.\n\n* __app__: The Express application to set up `express-ws` on.\n* __server__: *Optional.* When using a custom `http.Server`, you should pass it in here, so that `express-ws` can use it to set up the WebSocket upgrade handlers. If you don't specify a `server`, you will only be able to use it with the server that is created automatically when you call `app.listen`.\n* __options__: *Optional.* An object containing further options.\n  * __leaveRouterUntouched:__ Set this to `true` to keep `express-ws` from modifying the Router prototype. You will have to manually `applyTo` every Router that you wish to make `.ws` available on, when this is enabled.\n\nThis function will return a new `express-ws` API object, which will be referred to as `wsInstance` in the rest of the documentation.\n\n### wsInstance.app\n\nThis property contains the `app` that `express-ws` was set up on.\n\n### wsInstance.getWss()\n\nReturns the underlying WebSocket server/handler. You can use `wsInstance.getWss().clients` to obtain a list of all the connected WebSocket clients for this server.\n\nNote that this list will include *all* clients, not just those for a specific route - this means that it's often *not* a good idea to use this for broadcasts, for example.\n\n### wsInstance.applyTo(router)\n\nSets up `express-ws` on the given `router` (or other Router-like object). You will only need this in two scenarios:\n\n1. You have enabled `options.leaveRouterUntouched`, or\n2. You are using a custom router that is not based on the express.Router prototype.\n\nIn most cases, you won't need this at all.\n\n## Development\n\nThis module is written in ES6, and uses Babel for compilation. What this means in practice:\n\n* The source code lives in the `src/` directory.\n* After changing this code, make sure to run `npm run build` to compile it.\n",
  "readmeFilename": "README.md",
  "_id": "express-ws@2.0.0-rc.1",
  "_from": "express-ws@2.0.0-rc.1"
}
