{ "_args": [ [ { "raw": "connect-timeout@~1.6.2", "scope": null, "escapedName": "connect-timeout", "name": "connect-timeout", "rawSpec": "~1.6.2", "spec": ">=1.6.2 <1.7.0", "type": "range" }, "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/connect" ] ], "_from": "connect-timeout@>=1.6.2 <1.7.0", "_id": "connect-timeout@1.6.2", "_inCache": true, "_location": "/connect-timeout", "_npmUser": { "name": "dougwilson", "email": "doug@somethingdoug.com" }, "_npmVersion": "1.4.28", "_phantomChildren": { "inherits": "2.0.3", "statuses": "1.4.0" }, "_requested": { "raw": "connect-timeout@~1.6.2", "scope": null, "escapedName": "connect-timeout", "name": "connect-timeout", "rawSpec": "~1.6.2", "spec": ">=1.6.2 <1.7.0", "type": "range" }, "_requiredBy": [ "/connect" ], "_resolved": "https://registry.npmjs.org/connect-timeout/-/connect-timeout-1.6.2.tgz", "_shasum": "de9a5ec61e33a12b6edaab7b5f062e98c599b88e", "_shrinkwrap": null, "_spec": "connect-timeout@~1.6.2", "_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/connect", "bugs": { "url": "https://github.com/expressjs/timeout/issues" }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, { "name": "Jonathan Ong", "email": "me@jongleberry.com", "url": "http://jongleberry.com" } ], "dependencies": { "debug": "~2.2.0", "http-errors": "~1.3.1", "ms": "0.7.1", "on-headers": "~1.0.0" }, "description": "timeout middleware", "devDependencies": { "istanbul": "0.3.9", "mocha": "~2.2.4", "supertest": "~0.15.0" }, "directories": {}, "dist": { "shasum": "de9a5ec61e33a12b6edaab7b5f062e98c599b88e", "tarball": "https://registry.npmjs.org/connect-timeout/-/connect-timeout-1.6.2.tgz" }, "engines": { "node": ">= 0.8" }, "files": [ "LICENSE", "HISTORY.md", "index.js" ], "gitHead": "f0042a0555ae52f4407be39a7635715234443417", "homepage": "https://github.com/expressjs/timeout#readme", "license": "MIT", "maintainers": [ { "name": "aaron", "email": "aaron.heckmann+github@gmail.com" }, { "name": "rauchg", "email": "rauchg@gmail.com" }, { "name": "jongleberry", "email": "jonathanrichardong@gmail.com" }, { "name": "dougwilson", "email": "doug@somethingdoug.com" }, { "name": "tjholowaychuk", "email": "tj@vision-media.ca" }, { "name": "mscdex", "email": "mscdex@mscdex.net" }, { "name": "fishrock123", "email": "fishrock123@rocketmail.com" }, { "name": "defunctzombie", "email": "shtylman@gmail.com" } ], "name": "connect-timeout", "optionalDependencies": {}, "readme": "# connect-timeout\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Build Status][travis-image]][travis-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n[![Gratipay][gratipay-image]][gratipay-url]\n\nTimes out the request in `ms`, defaulting to `5000`.\n\n## Install\n\n```sh\n$ npm install connect-timeout\n```\n\n## API\n\n**NOTE** This module is not recommend as a \"top-level\" middleware (i.e.\n`app.use(timeout('5s'))`) unless you take precautions to halt your own\nmiddleware processing. See [as top-level middleware](#as-top-level-middleware)\nfor how to use as a top-level middleware.\n\n### timeout(time, [options])\n\nReturns middleware that times out in `time` milliseconds. `time` can also\nbe a string accepted by the [ms](https://www.npmjs.org/package/ms#readme)\nmodule. On timeout, `req` will emit `\"timeout\"`.\n\n#### Options\n\nThe `timeout` function takes an optional `options` object that may contain\nany of the following keys:\n\n##### respond\n\nControls if this module will \"respond\" in the form of forwarding an error.\nIf `true`, the timeout error is passed to `next()` so that you may customize\nthe response behavior. This error has a `.timeout` property as well as\n`.status == 503`. This defaults to `true`.\n\n### req.clearTimeout()\n\nClears the timeout on the request. The timeout is completely removed and\nwill not fire for this request in the future.\n\n### req.timedout\n\n`true` if timeout fired; `false` otherwise.\n\n## Examples\n\n### as top-level middleware\n\nBecause of the way middleware processing works, this once this module\npasses the request to the next middleware (which it has to do in order\nfor you to do work), it can no longer stop the flow, so you must take\ncare to check if the request has timedout before you continue to act\non the request.\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('5s'));\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('5s'), 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\n\n```javascript\nvar bodyParser = require('body-parser');\nvar connect = require('connect');\nvar timeout = require('connect-timeout');\n\nvar app = require('connect');\napp.use('/save', timeout('5s'), 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## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/connect-timeout.svg\n[npm-url]: https://npmjs.org/package/connect-timeout\n[travis-image]: https://img.shields.io/travis/expressjs/timeout/master.svg\n[travis-url]: https://travis-ci.org/expressjs/timeout\n[coveralls-image]: https://img.shields.io/coveralls/expressjs/timeout/master.svg\n[coveralls-url]: https://coveralls.io/r/expressjs/timeout?branch=master\n[downloads-image]: https://img.shields.io/npm/dm/connect-timeout.svg\n[downloads-url]: https://npmjs.org/package/connect-timeout\n[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg\n[gratipay-url]: https://www.gratipay.com/dougwilson/\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/expressjs/timeout.git" }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot --check-leaks test/" }, "version": "1.6.2" }