https://github.com/hex7c0/timeout-request
http timeout request middleware for Nodejs
https://github.com/hex7c0/timeout-request
nodejs timeout timer
Last synced: 2 months ago
JSON representation
http timeout request middleware for Nodejs
- Host: GitHub
- URL: https://github.com/hex7c0/timeout-request
- Owner: hex7c0
- License: apache-2.0
- Created: 2014-07-24T18:56:34.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2024-03-25T22:51:38.000Z (about 2 years ago)
- Last Synced: 2024-04-13T19:19:46.452Z (about 2 years ago)
- Topics: nodejs, timeout, timer
- Language: JavaScript
- Homepage: https://github.com/hex7c0/timeout-request
- Size: 259 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# [timeout-request](https://github.com/hex7c0/timeout-request)
[](https://www.npmjs.com/package/timeout-request)
[](https://travis-ci.org/hex7c0/timeout-request)
[](https://ci.appveyor.com/project/hex7c0/timeout-request)
[](https://david-dm.org/hex7c0/timeout-request)
[](https://coveralls.io/r/hex7c0/timeout-request)
Set the number of milliseconds that a script is allowed to run in [nodejs](http://nodejs.org/).
If this timeout is reached, `res.end()` or custom callback will be called
## Installation
Install through NPM
```bash
npm install timeout-request
```
or
```bash
git clone git://github.com/hex7c0/timeout-request.git
```
## API
inside expressjs project
```js
var timeout = require('timeout-request');
var app = require('express')();
app.use(timeout());
```
### timeout(options)
#### options
- `milliseconds` - **Number** Number of milliseconds before callback *(default "5000")*
- `header` - **Boolean** If enabled, check `res._header` before callback *(default "false")*
- `data` - **Object** Object passed to custom callback after `req` and `res` *(default "null")*
- `callback` - **Function** Custom callback instead of `res.end` *(default "null")*
## Examples
Take a look at my [examples](examples)
### [License Apache2](LICENSE)