{
  "name": "connect-timeout",
  "description": "timeout middleware",
  "version": "1.1.0",
  "author": {
    "name": "Jonathan Ong",
    "email": "me@jongleberry.com",
    "url": "http://jongleberry.com"
  },
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://github.com/expressjs/timeout.git"
  },
  "bugs": {
    "url": "https://github.com/expressjs/timeout/issues"
  },
  "dependencies": {
    "debug": "0.8.1"
  },
  "devDependencies": {
    "mocha": ">= 1.18.0 < 2.0",
    "should": ">= 3.3.0 < 4.0",
    "supertest": "*",
    "connect": "*"
  },
  "engines": {
    "node": ">= 0.8"
  },
  "scripts": {
    "test": "mocha --reporter spec --require should"
  },
  "readme": "# connect-timeout [![Build Status](https://travis-ci.org/expressjs/timeout.svg)](https://travis-ci.org/expressjs/timeout) [![NPM version](https://badge.fury.io/js/connect-timeout.svg)](http://badge.fury.io/js/connect-timeout)\n\nTimes out the request in `ms`, defaulting to `5000`.\n\n## Install\n\n    npm install connect-timeout\n\n## API\n\n**NOTE** This module is not recommend as a \"top-level\" middleware (i.e. do not recommend for use as `app.use(timeout(5000))`).\n\n### timeout(ms, options)\n\nReturns middleware that times out in `ms` milliseconds. On timeout, `req` will emit `\"timeout\"`.\n\n#### options\n\n* `respond` - If `true`, the timeout error is passed to `next()` so that you may customize the response behavior. This error has a `.timeout` property as well as `.status == 503`. This defaults to `true`.\n\n### req.clearTimeout()\n\nClears the timeout on the request.\n\n### req.timedout\n\n`true` if timeout fired; `false` otherwise.\n\n## Examples\n\n### as top-level middleware\n\n```javascript\nvar express = require('express');\nvar timeout = require('connect-timeout');\n\n// example of using this top-level; note the use of haltOnTimedout\n// after every middleware; it will stop the request flow on a timeout\nvar app = express();\napp.use(timeout(5000));\napp.use(bodyParser());\napp.use(haltOnTimedout);\napp.use(cookieParser());\napp.use(haltOnTimedout);\n\n// Add your routes here, etc.\n\nfunction haltOnTimedout(req, res, next){\n  if (!req.timedout) next();\n}\n\napp.listen(3000);\n```\n\n### express 3.x\n\n```javascript\nvar express = require('express');\nvar bodyParser = require('body-parser');\nvar timeout = require('connect-timeout');\n\nvar app = express();\napp.post('/save', timeout(5000), bodyParser.json(), haltOnTimedout, function(req, res, next){\n  savePost(req.body, function(err, id){\n    if (err) return next(err);\n    if (req.timedout) return;\n    res.send('saved as id ' + id);\n  });\n});\n\nfunction haltOnTimedout(req, res, next){\n  if (!req.timedout) next();\n}\n\nfunction savePost(post, cb){\n  setTimeout(function(){\n    cb(null, ((Math.random()* 40000) >>> 0));\n  }, (Math.random()* 7000) >>> 0));\n}\n\napp.listen(3000);\n```\n\n### connect 2.x\n\n```javascript\nvar connect = require('connect');\nvar timeout = require('connect-timeout');\n\nvar app = require('connect');\napp.use('/save', timeout(5000), connect.json(), haltOnTimedout, function(req, res, next){\n  savePost(req.body, function(err, id){\n    if (err) return next(err);\n    if (req.timedout) return;\n    res.send('saved as id ' + id);\n  });\n});\n\nfunction haltOnTimedout(req, res, next){\n  if (!req.timedout) next();\n}\n\nfunction savePost(post, cb){\n  setTimeout(function(){\n    cb(null, ((Math.random()* 40000) >>> 0));\n  }, (Math.random()* 7000) >>> 0));\n}\n\napp.listen(3000);\n```\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n",
  "readmeFilename": "README.md",
  "homepage": "https://github.com/expressjs/timeout",
  "_id": "connect-timeout@1.1.0",
  "_from": "connect-timeout@1.1.0"
}
