Skip to content

Commit

Permalink
feat(adapter-node-http): Use nock under the hood instead of custom…
Browse files Browse the repository at this point in the history
… implementation (#166)

BREAKING CHANGE: The node-http adapter no longer accepts the `transports` option
  • Loading branch information
offirgolan authored Jan 29, 2019
1 parent 07b2b4e commit 62374f4
Show file tree
Hide file tree
Showing 32 changed files with 579 additions and 622 deletions.
24 changes: 1 addition & 23 deletions docs/adapters/node-http.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Node HTTP Adapter

The node-http adapter provides a low level nodejs http request adapter that patches the [http](https://nodejs.org/api/http.html) and [https](https://nodejs.org/api/https.html) modules in nodejs for seamless recording and replaying of requests.
The node-http adapter provides a low level nodejs http request adapter that uses [nock](https://github.com/nock/nock) to patch the [http](https://nodejs.org/api/http.html) and [https](https://nodejs.org/api/https.html) modules in nodejs for seamless recording and replaying of requests.

## Installation

Expand Down Expand Up @@ -42,25 +42,3 @@ polly.connectTo('node-http');
// Disconnect using the `disconnectFrom` API
polly.disconnectFrom('node-http');
```

## Options

### transports

_Type_: `Array`
_Default_: `['http', 'https']`

The node transport modules to patch. By default, both the [http](https://nodejs.org/api/http.html) and [https](https://nodejs.org/api/https.html) modules are patched. In Node 8 and
below, the https module patching is skipped as it uses the http methods under the hood.

**Example**

```js
polly.configure({
adapterOptions: {
'node-http': {
transports: ['http']
}
}
});
```
3 changes: 2 additions & 1 deletion docs/server/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## HTTP Methods

The `get`, `put`, `post`, `patch`, `delete`, `head`, and `options` HTTP methods
The `GET`, `PUT`, `POST`, `PATCH`, `DELETE`, `MERGE`, `HEAD`, and `OPTIONS` HTTP methods
have a corresponding method on the server instance.

```js
Expand All @@ -11,6 +11,7 @@ server.put('/ping');
server.post('/ping');
server.patch('/ping');
server.delete('/ping');
server.merge('/ping');
server.head('/ping');
server.options('/ping');
```
Expand Down
2 changes: 1 addition & 1 deletion packages/@pollyjs/adapter-node-http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![npm version](https://badge.fury.io/js/%40pollyjs%2Fadapter-node-http.svg)](https://badge.fury.io/js/%40pollyjs%2Fadapter-node-http)
[![license](https://img.shields.io/github/license/Netflix/pollyjs.svg)](http://www.apache.org/licenses/LICENSE-2.0)

The `@pollyjs/adapter-node-http` package provides a low level nodejs http request adapter that patches the [http](https://nodejs.org/api/http.html) and [https](https://nodejs.org/api/https.html) modules in nodejs for seamless recording and replaying of requests.
The `@pollyjs/adapter-node-http` package provides a low level nodejs http request adapter that uses [nock](https://github.com/nock/nock) to patch the [http](https://nodejs.org/api/http.html) and [https](https://nodejs.org/api/https.html) modules in nodejs for seamless recording and replaying of requests.

## Installation

Expand Down
1 change: 1 addition & 0 deletions packages/@pollyjs/adapter-node-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@pollyjs/adapter": "^1.4.1",
"@pollyjs/utils": "^1.4.1",
"lodash-es": "^4.17.11",
"nock": "^10.0.6",
"semver": "^5.6.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@pollyjs/adapter-node-http/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import createNodeConfig from '../../../build-scripts/rollup.node.config';

export default createNodeConfig({
external: ['http', 'https', 'url']
external: ['http', 'https', 'url', 'stream']
});
2 changes: 1 addition & 1 deletion packages/@pollyjs/adapter-node-http/rollup.config.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import createNodeTestConfig from '../../../build-scripts/rollup.node.test.config';

export default createNodeTestConfig({
external: ['http', 'https', 'url', 'crypto']
external: ['http', 'https', 'url', 'stream', 'crypto']
});
38 changes: 0 additions & 38 deletions packages/@pollyjs/adapter-node-http/src/-private/http-wrapper.js

This file was deleted.

Loading

0 comments on commit 62374f4

Please sign in to comment.