timeout-request
Version:
http timeout request middleware
49 lines (33 loc) • 1.66 kB
Markdown
# [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)