Skip to content

Commit

Permalink
feat: change import path for node:http (#105)
Browse files Browse the repository at this point in the history
* chore: move files related to node:http

* feat: change import path for node:http

BREAKING CHANGE: you should import `'http-cookie-agent/node:http'` instead of `'http-cookie-agent'`.
  • Loading branch information
3846masa committed May 7, 2022
1 parent e4d7d4f commit 6260bdc
Show file tree
Hide file tree
Showing 44 changed files with 52 additions and 66 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Pass `http-cookie-agent` to HTTP clients instead of http(s).Agent.

```js
import { CookieJar } from 'tough-cookie';
import { HttpCookieAgent, HttpsCookieAgent, MixedCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent, MixedCookieAgent } from 'http-cookie-agent/node:http';

const jar = new CookieJar();

Expand Down Expand Up @@ -77,7 +77,7 @@ await fetch('https://example.com');
import https from 'node:https';

import { CookieJar } from 'tough-cookie';
import { HttpsCookieAgent } from 'http-cookie-agent';
import { HttpsCookieAgent } from 'http-cookie-agent/node:http';

const jar = new CookieJar();
const agent = new HttpsCookieAgent({ jar });
Expand All @@ -92,7 +92,7 @@ https.get('https://example.com', { agent }, (res) => {
```js
import axios from 'axios';
import { CookieJar } from 'tough-cookie';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';

const jar = new CookieJar();

Expand All @@ -109,7 +109,7 @@ await client.get('https://example.com');
```js
import fetch from 'node-fetch';
import { CookieJar } from 'tough-cookie';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';

const jar = new CookieJar();

Expand All @@ -132,7 +132,7 @@ See https://github.com/sindresorhus/got/tree/v11.8.2#cookies.
```js
import got from 'got';
import { CookieJar } from 'tough-cookie';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';

const jar = new CookieJar();

Expand All @@ -155,7 +155,7 @@ See https://github.com/visionmedia/superagent/blob/v6.1.0/docs/index.md#saving-c
```js
import superagent from 'superagent';
import { CookieJar } from 'tough-cookie';
import { MixedCookieAgent } from 'http-cookie-agent';
import { MixedCookieAgent } from 'http-cookie-agent/node:http';

const jar = new CookieJar();
const mixedAgent = new MixedCookieAgent({ jar });
Expand All @@ -174,7 +174,7 @@ See https://github.com/request/request/tree/v2.88.1#examples.
```js
import request from 'request';
import { CookieJar } from 'tough-cookie';
import { MixedCookieAgent } from 'http-cookie-agent';
import { MixedCookieAgent } from 'http-cookie-agent/node:http';

const jar = new CookieJar();

Expand All @@ -192,7 +192,7 @@ client.get('https://example.com', (_err, _res) => {
```js
import needle from 'needle';
import { CookieJar } from 'tough-cookie';
import { MixedCookieAgent } from 'http-cookie-agent';
import { MixedCookieAgent } from 'http-cookie-agent/node:http';

const jar = new CookieJar();

Expand All @@ -206,7 +206,7 @@ await needle('get', 'https://example.com', {
```js
import phin from 'phin';
import { CookieJar } from 'tough-cookie';
import { MixedCookieAgent } from 'http-cookie-agent';
import { MixedCookieAgent } from 'http-cookie-agent/node:http';

const jar = new CookieJar();

Expand All @@ -223,7 +223,7 @@ await phin({
```js
import Wreck from '@hapi/wreck';
import { CookieJar } from 'tough-cookie';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';

const jar = new CookieJar();

Expand All @@ -243,7 +243,7 @@ await client.get('https://example.com');
```js
import urllib from 'urllib';
import { CookieJar } from 'tough-cookie';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';

const jar = new CookieJar();

Expand All @@ -264,7 +264,7 @@ import https from 'node:https';

import { HttpsAgent as KeepAliveAgent } from 'agentkeepalive';
import { CookieJar } from 'tough-cookie';
import { createCookieAgent } from 'http-cookie-agent';
import { createCookieAgent } from 'http-cookie-agent/node:http';

const Agent = createCookieAgent(KeepAliveAgent);

Expand Down
2 changes: 1 addition & 1 deletion examples/agentkeepalive/basic.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import https from 'node:https';

import { HttpsAgent as KeepAliveAgent } from 'agentkeepalive';
import { createCookieAgent } from 'http-cookie-agent';
import { createCookieAgent } from 'http-cookie-agent/node:http';
import { CookieJar } from 'tough-cookie';

const KeepAliveCookieAgent = createCookieAgent(KeepAliveAgent);
Expand Down
2 changes: 1 addition & 1 deletion examples/axios/basic.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';
import { CookieJar } from 'tough-cookie';

const jar = new CookieJar();
Expand Down
2 changes: 1 addition & 1 deletion examples/axios/default.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';
import { CookieJar } from 'tough-cookie';

const jar = new CookieJar();
Expand Down
2 changes: 1 addition & 1 deletion examples/axios/instance.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';
import { CookieJar } from 'tough-cookie';

const jar = new CookieJar();
Expand Down
2 changes: 1 addition & 1 deletion examples/got/basic.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import got from 'got';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';
import { CookieJar } from 'tough-cookie';

const jar = new CookieJar();
Expand Down
2 changes: 1 addition & 1 deletion examples/got/instance.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import got from 'got';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';
import { CookieJar } from 'tough-cookie';

const jar = new CookieJar();
Expand Down
2 changes: 1 addition & 1 deletion examples/http-proxy-agent/basic.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import http from 'node:http';

import { createCookieAgent } from 'http-cookie-agent';
import { createCookieAgent } from 'http-cookie-agent/node:http';
import httpProxy from 'http-proxy';
import httpProxyAgent from 'http-proxy-agent';
import { CookieJar } from 'tough-cookie';
Expand Down
2 changes: 1 addition & 1 deletion examples/needle/basic.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MixedCookieAgent } from 'http-cookie-agent';
import { MixedCookieAgent } from 'http-cookie-agent/node:http';
import needle from 'needle';
import { CookieJar } from 'tough-cookie';

Expand Down
2 changes: 1 addition & 1 deletion examples/node-fetch/basic.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';
import fetch from 'node-fetch';
import { CookieJar } from 'tough-cookie';

Expand Down
2 changes: 1 addition & 1 deletion examples/node/http.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import http from 'node:http';

import { HttpCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent } from 'http-cookie-agent/node:http';
import { CookieJar } from 'tough-cookie';

const jar = new CookieJar();
Expand Down
2 changes: 1 addition & 1 deletion examples/node/https.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import https from 'node:https';

import { HttpsCookieAgent } from 'http-cookie-agent';
import { HttpsCookieAgent } from 'http-cookie-agent/node:http';
import { CookieJar } from 'tough-cookie';

const jar = new CookieJar();
Expand Down
2 changes: 1 addition & 1 deletion examples/phin/basic.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MixedCookieAgent } from 'http-cookie-agent';
import { MixedCookieAgent } from 'http-cookie-agent/node:http';
import phin from 'phin';
import { CookieJar } from 'tough-cookie';

Expand Down
2 changes: 1 addition & 1 deletion examples/phin/instance.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MixedCookieAgent } from 'http-cookie-agent';
import { MixedCookieAgent } from 'http-cookie-agent/node:http';
import phin from 'phin';
import { CookieJar } from 'tough-cookie';

Expand Down
2 changes: 1 addition & 1 deletion examples/request/basic.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MixedCookieAgent } from 'http-cookie-agent';
import { MixedCookieAgent } from 'http-cookie-agent/node:http';
import request from 'request';
import { CookieJar } from 'tough-cookie';

Expand Down
2 changes: 1 addition & 1 deletion examples/request/instance.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MixedCookieAgent } from 'http-cookie-agent';
import { MixedCookieAgent } from 'http-cookie-agent/node:http';
import request from 'request';
import { CookieJar } from 'tough-cookie';

Expand Down
2 changes: 1 addition & 1 deletion examples/superagent/basic.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MixedCookieAgent } from 'http-cookie-agent';
import { MixedCookieAgent } from 'http-cookie-agent/node:http';
import superagent from 'superagent';
import { CookieJar } from 'tough-cookie';

Expand Down
2 changes: 1 addition & 1 deletion examples/superagent/instance.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MixedCookieAgent } from 'http-cookie-agent';
import { MixedCookieAgent } from 'http-cookie-agent/node:http';
import superagent from 'superagent';
import { CookieJar } from 'tough-cookie';

Expand Down
2 changes: 1 addition & 1 deletion examples/urllib/basic.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';
import { CookieJar } from 'tough-cookie';
import urllib from 'urllib';

Expand Down
2 changes: 1 addition & 1 deletion examples/urllib/instance.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';
import { CookieJar } from 'tough-cookie';
import urllib from 'urllib';

Expand Down
2 changes: 1 addition & 1 deletion examples/wreck/basic.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Wreck from '@hapi/wreck';
import { MixedCookieAgent } from 'http-cookie-agent';
import { MixedCookieAgent } from 'http-cookie-agent/node:http';
import { CookieJar } from 'tough-cookie';

const jar = new CookieJar();
Expand Down
2 changes: 1 addition & 1 deletion examples/wreck/default.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Wreck from '@hapi/wreck';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';
import { CookieJar } from 'tough-cookie';

const jar = new CookieJar();
Expand Down
2 changes: 1 addition & 1 deletion examples/wreck/instance.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Wreck from '@hapi/wreck';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent';
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/node:http';
import { CookieJar } from 'tough-cookie';

const jar = new CookieJar();
Expand Down
4 changes: 2 additions & 2 deletions index.d.ts → node:http/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as http from 'node:http';
import * as https from 'node:https';
import http from 'node:http';
import https from 'node:https';

import { CookieJar } from 'tough-cookie';

Expand Down
1 change: 1 addition & 0 deletions node:http/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../dist/node:http');
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@
"license": "MIT",
"author": "3846masa <3846masahiro+git@gmail.com>",
"exports": {
".": "./dist/index.js",
"./node:http": "./node:http/index.js",
"./undici": "./undici/index.js"
},
"main": "dist/index.js",
"types": "index.d.ts",
"files": [
"dist",
"undici",
"index.d.ts",
"node:http",
"!**/__tests__"
],
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import KeepAliveAgent from 'agentkeepalive';
import test from 'ava';
import { CookieJar } from 'tough-cookie';

import { createTestServer } from '../../__tests__/helpers.mjs';
import { createCookieAgent } from '../index.js';

import { createTestServer } from './helpers.mjs';

const KeepAliveCookieAgent = createCookieAgent(KeepAliveAgent);

export function request(url: string, options: http.RequestOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import test from 'ava';
import axios from 'axios';
import { CookieJar } from 'tough-cookie';

import { createTestServer, readStream } from '../../__tests__/helpers.mjs';
import { HttpCookieAgent } from '../index.js';

import { createTestServer, readStream } from './helpers.mjs';

test('should set cookies to CookieJar from Set-Cookie header', async (t) => {
const jar = new CookieJar();
const agent = new HttpCookieAgent({ jar });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import test from 'ava';
import got from 'got';
import { CookieJar } from 'tough-cookie';

import { createTestServer, readStream } from '../../__tests__/helpers.mjs';
import { HttpCookieAgent } from '../index.js';

import { createTestServer, readStream } from './helpers.mjs';

test('should set cookies to CookieJar from Set-Cookie header', async (t) => {
const jar = new CookieJar();
const agent = new HttpCookieAgent({ jar });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import test from 'ava';
import hpa from 'http-proxy-agent';
import { CookieJar } from 'tough-cookie';

import { createTestServerWithProxy } from '../../__tests__/helpers.mjs';
import { createCookieAgent } from '../create_cookie_agent.js';

import { createTestServerWithProxy } from './helpers.mjs';

const HttpProxyCookieAgent = createCookieAgent(hpa.HttpProxyAgent);

export function request(url: string, options: http.RequestOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import http from 'node:http';
import test from 'ava';
import { CookieJar } from 'tough-cookie';

import { createTestServer, readStream } from '../../__tests__/helpers.mjs';
import { HttpCookieAgent } from '../index.js';

import { createTestServer, readStream } from './helpers.mjs';

export function request(url: string, options: http.RequestOptions) {
const req = http.request(url, options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import http from 'node:http';
import test from 'ava';
import { CookieJar } from 'tough-cookie';

import { createTestServer } from '../../__tests__/helpers.mjs';
import { MixedCookieAgent } from '../index.js';

import { createTestServer } from './helpers.mjs';

export function request(url: string, options: http.RequestOptions) {
const req = http.request(url, options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import test from 'ava';
import needle from 'needle';
import { CookieJar } from 'tough-cookie';

import { createTestServer, readStream } from '../../__tests__/helpers.mjs';
import { HttpCookieAgent } from '../index.js';

import { createTestServer, readStream } from './helpers.mjs';

test('should set cookies to CookieJar from Set-Cookie header', async (t) => {
const jar = new CookieJar();
const agent = new HttpCookieAgent({ jar });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import test from 'ava';
import fetch from 'node-fetch';
import { CookieJar } from 'tough-cookie';

import { createTestServer, readStream } from '../../__tests__/helpers.mjs';
import { HttpCookieAgent } from '../index.js';

import { createTestServer, readStream } from './helpers.mjs';

test('should set cookies to CookieJar from Set-Cookie header', async (t) => {
const jar = new CookieJar();
const agent = new HttpCookieAgent({ jar });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import test from 'ava';
import phin from 'phin';
import { CookieJar } from 'tough-cookie';

import { createTestServer, readStream } from '../../__tests__/helpers.mjs';
import { HttpCookieAgent } from '../index.js';

import { createTestServer, readStream } from './helpers.mjs';

test('should set cookies to CookieJar from Set-Cookie header', async (t) => {
const jar = new CookieJar();
const agent = new HttpCookieAgent({ jar });
Expand Down
Loading

0 comments on commit 6260bdc

Please sign in to comment.