Skip to content

Commit ff29111

Browse files
author
Glynn Bird
committed
added migration guide
1 parent e95b56b commit ff29111

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Offical [Apache CouchDB](https://couchdb.apache.org/) library for [Node.js](https://nodejs.org/).
66

77
> Note: Nano >=11.0.0 is a **breaking change for Node.js versions 16 and older**. Nano 11 uses Node.js's built-in "fetch" HTTP client but this is only available in Node.js versions 18 or later. If you are using Node 16 or older then continue using Nano 10.
8+
> See our [migration guide](migration_guide_v10_to_v11.md) for moving from Nano 10 to Nano 11.
89
910
Features:
1011

migration_guide_v10_to_v11.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Migrating from Nano 10 to Nano 11
2+
3+
Nano 10 uses the Axios library as an HTTP/HTTPS client. Keeping up with changes to Axios and its dependencies made maintaining this library a chore, so as of Nano 11 we use Node.js's built-in _fetch_ API as our HTTP client. This makes Nano a _zero dependency_ library which makes for faster installs, easier maintenance and slightly better performance.
4+
5+
There are some things to bear in mind if you are switching from Nano 10 to Nano 11, so please consider the following advice carefully before you do.
6+
7+
## Node.js versions
8+
9+
> ** Nano 11 is a breaking change for users of Node.s 16 or earlier **
10+
11+
Nano 11 is only compatible with Node.js versions 18 and older, because it is only these Node versions that have the [fetch](https://nodejs.org/dist/latest-v18.x/docs/api/globals.html#fetch) HTTP client baked in. See [Node.js's Long-term Support page](https://nodejs.org/en/about/previous-releases) to see which are the currently supported and maintained versions. In short:
12+
13+
- If you are using Node.js 18 or newer, use Nano 11.
14+
- If you need to use Node.js 16 or older, use Nano 10.
15+
16+
Nano 10 may continue to receive some security fixes for a time, but Nano 11 represents the future of this project and at some point, support for Nano 10 will cease.
17+
18+
## Agent options
19+
20+
None of Nano's API has changed _except_ when a user is supplying non-default connection handling parameters. Gone is `requestDefaults` which dates back to the "request" days and instead an optional `agentOptions` can be provided which is documented in the README and in TypeScript.
21+
22+
```js
23+
const agentOptions = {
24+
bodyTimeout: 30000,
25+
headersTimeout: 30000,
26+
keepAliveMaxTimeout: 600000,
27+
keepAliveTimeout: 30000,
28+
keepAliveTimeoutThreshold: 1000,
29+
maxHeaderSize: 16384,
30+
maxResponseSize: -1,
31+
pipelining: 6,
32+
connect: {
33+
timeout: 10000
34+
},
35+
strictContentLength: true,
36+
connections: null,
37+
maxRedirections: 0
38+
}
39+
const undici = require('undici')
40+
const undiciOptions = new undici.Agent(agentOptions)
41+
const nano = Nano({ url: 'http://127.0.0.1:5984', undiciOptions })
42+
```
43+
44+
> Note: to supply a custom agent, you will need the [undici](https://www.npmjs.com/package/undici) module as a dependency in your own project. Undici is the library that powers Node.js's _fetch_ API but its "Agent" is not programmatically accessible unless undici is imported separately.
45+

0 commit comments

Comments
 (0)