Skip to content

Commit e3675e3

Browse files
committed
docs: readme tweaks
1 parent 7fa0213 commit e3675e3

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

README.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,28 @@ $ npm install connect-timeout
1616

1717
## API
1818

19-
**NOTE** This module is not recommend as a "top-level" middleware (i.e. `app.use(timeout('5s'))`) unless
20-
you take precautions to halt your own middleware processing. See [as top-level middleware](#as-top-level-middleware)
19+
**NOTE** This module is not recommend as a "top-level" middleware (i.e.
20+
`app.use(timeout('5s'))`) unless you take precautions to halt your own
21+
middleware processing. See [as top-level middleware](#as-top-level-middleware)
2122
for how to use as a top-level middleware.
2223

23-
### timeout(time, options)
24+
### timeout(time, [options])
2425

25-
Returns middleware that times out in `time` milliseconds. `time` can also be a string accepted by the [ms](https://www.npmjs.org/package/ms#readme) module. On timeout, `req` will emit `"timeout"`.
26+
Returns middleware that times out in `time` milliseconds. `time` can also
27+
be a string accepted by the [ms](https://www.npmjs.org/package/ms#readme)
28+
module. On timeout, `req` will emit `"timeout"`.
2629

27-
#### options
30+
#### Options
2831

29-
* `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`.
32+
The `timeout` function takes an optional `options` object that may contain
33+
any of the following keys:
34+
35+
##### respond
36+
37+
Controls if this module will "respond" in the form of forwarding an error.
38+
If `true`, the timeout error is passed to `next()` so that you may customize
39+
the response behavior. This error has a `.timeout` property as well as
40+
`.status == 503`. This defaults to `true`.
3041

3142
### req.clearTimeout()
3243

@@ -40,10 +51,11 @@ Clears the timeout on the request.
4051

4152
### as top-level middleware
4253

43-
Because of the way middleware processing works, this once this module passes the request
44-
to the next middleware (which it has to do in order for you to do work), it can no longer
45-
stop the flow, so you must take care to check if the request has timedout before you
46-
continue to act on the request.
54+
Because of the way middleware processing works, this once this module
55+
passes the request to the next middleware (which it has to do in order
56+
for you to do work), it can no longer stop the flow, so you must take
57+
care to check if the request has timedout before you continue to act
58+
on the request.
4759

4860
```javascript
4961
var express = require('express');

0 commit comments

Comments
 (0)