Skip to content

Commit d0cb8f6

Browse files
Merge pull request #682 from jenslys/feat-native-fetch
fix: replace node-fetch with native fetch
2 parents 77ae0dd + c75ede7 commit d0cb8f6

65 files changed

Lines changed: 908 additions & 1020 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

codegen/automation/actions/http/isomorphic-fetch.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
import {HttpLibrary, RequestContext, ResponseContext} from './http';
22
import { from, Observable } from '../rxjsStub';
3-
import fetch from "node-fetch";
3+
import { sendBufferedRequest } from '../../../../src/services/http/Transport';
44

55
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
66

77
public send(request: RequestContext): Observable<ResponseContext> {
8-
let method = request.getHttpMethod().toString();
9-
let body = request.getBody();
10-
11-
const resultPromise = fetch(request.getUrl(), {
12-
method: method,
13-
body: body as any,
8+
const resultPromise = sendBufferedRequest(request.getUrl(), {
9+
method: request.getHttpMethod().toString(),
10+
body: request.getBody(),
1411
headers: request.getHeaders(),
1512
agent: request.getAgent(),
16-
}).then((resp: any) => {
17-
const headers: { [name: string]: string } = {};
18-
resp.headers.forEach((value: string, name: string) => {
19-
headers[name] = value;
20-
});
21-
13+
}).then((response) => {
2214
const body = {
23-
text: () => resp.text(),
24-
binary: () => resp.buffer()
15+
text: () => response.text(),
16+
binary: () => response.binary()
2517
};
26-
return new ResponseContext(resp.status, headers, body);
18+
return new ResponseContext(response.status, response.headers, body);
2719
});
2820

2921
return from<Promise<ResponseContext>>(resultPromise);

codegen/cms/audit_logs/http/isomorphic-fetch.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
import {HttpLibrary, RequestContext, ResponseContext} from './http';
22
import { from, Observable } from '../rxjsStub';
3-
import fetch from "node-fetch";
3+
import { sendBufferedRequest } from '../../../../src/services/http/Transport';
44

55
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
66

77
public send(request: RequestContext): Observable<ResponseContext> {
8-
let method = request.getHttpMethod().toString();
9-
let body = request.getBody();
10-
11-
const resultPromise = fetch(request.getUrl(), {
12-
method: method,
13-
body: body as any,
8+
const resultPromise = sendBufferedRequest(request.getUrl(), {
9+
method: request.getHttpMethod().toString(),
10+
body: request.getBody(),
1411
headers: request.getHeaders(),
1512
agent: request.getAgent(),
16-
}).then((resp: any) => {
17-
const headers: { [name: string]: string } = {};
18-
resp.headers.forEach((value: string, name: string) => {
19-
headers[name] = value;
20-
});
21-
13+
}).then((response) => {
2214
const body = {
23-
text: () => resp.text(),
24-
binary: () => resp.buffer()
15+
text: () => response.text(),
16+
binary: () => response.binary()
2517
};
26-
return new ResponseContext(resp.status, headers, body);
18+
return new ResponseContext(response.status, response.headers, body);
2719
});
2820

2921
return from<Promise<ResponseContext>>(resultPromise);

codegen/cms/blogs/authors/http/isomorphic-fetch.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
import {HttpLibrary, RequestContext, ResponseContext} from './http';
22
import { from, Observable } from '../rxjsStub';
3-
import fetch from "node-fetch";
3+
import { sendBufferedRequest } from '../../../../../src/services/http/Transport';
44

55
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
66

77
public send(request: RequestContext): Observable<ResponseContext> {
8-
let method = request.getHttpMethod().toString();
9-
let body = request.getBody();
10-
11-
const resultPromise = fetch(request.getUrl(), {
12-
method: method,
13-
body: body as any,
8+
const resultPromise = sendBufferedRequest(request.getUrl(), {
9+
method: request.getHttpMethod().toString(),
10+
body: request.getBody(),
1411
headers: request.getHeaders(),
1512
agent: request.getAgent(),
16-
}).then((resp: any) => {
17-
const headers: { [name: string]: string } = {};
18-
resp.headers.forEach((value: string, name: string) => {
19-
headers[name] = value;
20-
});
21-
13+
}).then((response) => {
2214
const body = {
23-
text: () => resp.text(),
24-
binary: () => resp.buffer()
15+
text: () => response.text(),
16+
binary: () => response.binary()
2517
};
26-
return new ResponseContext(resp.status, headers, body);
18+
return new ResponseContext(response.status, response.headers, body);
2719
});
2820

2921
return from<Promise<ResponseContext>>(resultPromise);

codegen/cms/blogs/blog_posts/http/isomorphic-fetch.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
import {HttpLibrary, RequestContext, ResponseContext} from './http';
22
import { from, Observable } from '../rxjsStub';
3-
import fetch from "node-fetch";
3+
import { sendBufferedRequest } from '../../../../../src/services/http/Transport';
44

55
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
66

77
public send(request: RequestContext): Observable<ResponseContext> {
8-
let method = request.getHttpMethod().toString();
9-
let body = request.getBody();
10-
11-
const resultPromise = fetch(request.getUrl(), {
12-
method: method,
13-
body: body as any,
8+
const resultPromise = sendBufferedRequest(request.getUrl(), {
9+
method: request.getHttpMethod().toString(),
10+
body: request.getBody(),
1411
headers: request.getHeaders(),
1512
agent: request.getAgent(),
16-
}).then((resp: any) => {
17-
const headers: { [name: string]: string } = {};
18-
resp.headers.forEach((value: string, name: string) => {
19-
headers[name] = value;
20-
});
21-
13+
}).then((response) => {
2214
const body = {
23-
text: () => resp.text(),
24-
binary: () => resp.buffer()
15+
text: () => response.text(),
16+
binary: () => response.binary()
2517
};
26-
return new ResponseContext(resp.status, headers, body);
18+
return new ResponseContext(response.status, response.headers, body);
2719
});
2820

2921
return from<Promise<ResponseContext>>(resultPromise);

codegen/cms/blogs/tags/http/isomorphic-fetch.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
import {HttpLibrary, RequestContext, ResponseContext} from './http';
22
import { from, Observable } from '../rxjsStub';
3-
import fetch from "node-fetch";
3+
import { sendBufferedRequest } from '../../../../../src/services/http/Transport';
44

55
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
66

77
public send(request: RequestContext): Observable<ResponseContext> {
8-
let method = request.getHttpMethod().toString();
9-
let body = request.getBody();
10-
11-
const resultPromise = fetch(request.getUrl(), {
12-
method: method,
13-
body: body as any,
8+
const resultPromise = sendBufferedRequest(request.getUrl(), {
9+
method: request.getHttpMethod().toString(),
10+
body: request.getBody(),
1411
headers: request.getHeaders(),
1512
agent: request.getAgent(),
16-
}).then((resp: any) => {
17-
const headers: { [name: string]: string } = {};
18-
resp.headers.forEach((value: string, name: string) => {
19-
headers[name] = value;
20-
});
21-
13+
}).then((response) => {
2214
const body = {
23-
text: () => resp.text(),
24-
binary: () => resp.buffer()
15+
text: () => response.text(),
16+
binary: () => response.binary()
2517
};
26-
return new ResponseContext(resp.status, headers, body);
18+
return new ResponseContext(response.status, response.headers, body);
2719
});
2820

2921
return from<Promise<ResponseContext>>(resultPromise);

codegen/cms/domains/http/isomorphic-fetch.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
import {HttpLibrary, RequestContext, ResponseContext} from './http';
22
import { from, Observable } from '../rxjsStub';
3-
import fetch from "node-fetch";
3+
import { sendBufferedRequest } from '../../../../src/services/http/Transport';
44

55
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
66

77
public send(request: RequestContext): Observable<ResponseContext> {
8-
let method = request.getHttpMethod().toString();
9-
let body = request.getBody();
10-
11-
const resultPromise = fetch(request.getUrl(), {
12-
method: method,
13-
body: body as any,
8+
const resultPromise = sendBufferedRequest(request.getUrl(), {
9+
method: request.getHttpMethod().toString(),
10+
body: request.getBody(),
1411
headers: request.getHeaders(),
1512
agent: request.getAgent(),
16-
}).then((resp: any) => {
17-
const headers: { [name: string]: string } = {};
18-
resp.headers.forEach((value: string, name: string) => {
19-
headers[name] = value;
20-
});
21-
13+
}).then((response) => {
2214
const body = {
23-
text: () => resp.text(),
24-
binary: () => resp.buffer()
15+
text: () => response.text(),
16+
binary: () => response.binary()
2517
};
26-
return new ResponseContext(resp.status, headers, body);
18+
return new ResponseContext(response.status, response.headers, body);
2719
});
2820

2921
return from<Promise<ResponseContext>>(resultPromise);

codegen/cms/hubdb/http/isomorphic-fetch.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
import {HttpLibrary, RequestContext, ResponseContext} from './http';
22
import { from, Observable } from '../rxjsStub';
3-
import fetch from "node-fetch";
3+
import { sendBufferedRequest } from '../../../../src/services/http/Transport';
44

55
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
66

77
public send(request: RequestContext): Observable<ResponseContext> {
8-
let method = request.getHttpMethod().toString();
9-
let body = request.getBody();
10-
11-
const resultPromise = fetch(request.getUrl(), {
12-
method: method,
13-
body: body as any,
8+
const resultPromise = sendBufferedRequest(request.getUrl(), {
9+
method: request.getHttpMethod().toString(),
10+
body: request.getBody(),
1411
headers: request.getHeaders(),
1512
agent: request.getAgent(),
16-
}).then((resp: any) => {
17-
const headers: { [name: string]: string } = {};
18-
resp.headers.forEach((value: string, name: string) => {
19-
headers[name] = value;
20-
});
21-
13+
}).then((response) => {
2214
const body = {
23-
text: () => resp.text(),
24-
binary: () => resp.buffer()
15+
text: () => response.text(),
16+
binary: () => response.binary()
2517
};
26-
return new ResponseContext(resp.status, headers, body);
18+
return new ResponseContext(response.status, response.headers, body);
2719
});
2820

2921
return from<Promise<ResponseContext>>(resultPromise);

codegen/cms/pages/http/isomorphic-fetch.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
import {HttpLibrary, RequestContext, ResponseContext} from './http';
22
import { from, Observable } from '../rxjsStub';
3-
import fetch from "node-fetch";
3+
import { sendBufferedRequest } from '../../../../src/services/http/Transport';
44

55
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
66

77
public send(request: RequestContext): Observable<ResponseContext> {
8-
let method = request.getHttpMethod().toString();
9-
let body = request.getBody();
10-
11-
const resultPromise = fetch(request.getUrl(), {
12-
method: method,
13-
body: body as any,
8+
const resultPromise = sendBufferedRequest(request.getUrl(), {
9+
method: request.getHttpMethod().toString(),
10+
body: request.getBody(),
1411
headers: request.getHeaders(),
1512
agent: request.getAgent(),
16-
}).then((resp: any) => {
17-
const headers: { [name: string]: string } = {};
18-
resp.headers.forEach((value: string, name: string) => {
19-
headers[name] = value;
20-
});
21-
13+
}).then((response) => {
2214
const body = {
23-
text: () => resp.text(),
24-
binary: () => resp.buffer()
15+
text: () => response.text(),
16+
binary: () => response.binary()
2517
};
26-
return new ResponseContext(resp.status, headers, body);
18+
return new ResponseContext(response.status, response.headers, body);
2719
});
2820

2921
return from<Promise<ResponseContext>>(resultPromise);

codegen/cms/site_search/http/isomorphic-fetch.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
import {HttpLibrary, RequestContext, ResponseContext} from './http';
22
import { from, Observable } from '../rxjsStub';
3-
import fetch from "node-fetch";
3+
import { sendBufferedRequest } from '../../../../src/services/http/Transport';
44

55
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
66

77
public send(request: RequestContext): Observable<ResponseContext> {
8-
let method = request.getHttpMethod().toString();
9-
let body = request.getBody();
10-
11-
const resultPromise = fetch(request.getUrl(), {
12-
method: method,
13-
body: body as any,
8+
const resultPromise = sendBufferedRequest(request.getUrl(), {
9+
method: request.getHttpMethod().toString(),
10+
body: request.getBody(),
1411
headers: request.getHeaders(),
1512
agent: request.getAgent(),
16-
}).then((resp: any) => {
17-
const headers: { [name: string]: string } = {};
18-
resp.headers.forEach((value: string, name: string) => {
19-
headers[name] = value;
20-
});
21-
13+
}).then((response) => {
2214
const body = {
23-
text: () => resp.text(),
24-
binary: () => resp.buffer()
15+
text: () => response.text(),
16+
binary: () => response.binary()
2517
};
26-
return new ResponseContext(resp.status, headers, body);
18+
return new ResponseContext(response.status, response.headers, body);
2719
});
2820

2921
return from<Promise<ResponseContext>>(resultPromise);

codegen/cms/source_code/http/isomorphic-fetch.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
import {HttpLibrary, RequestContext, ResponseContext} from './http';
22
import { from, Observable } from '../rxjsStub';
3-
import fetch from "node-fetch";
3+
import { sendBufferedRequest } from '../../../../src/services/http/Transport';
44

55
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
66

77
public send(request: RequestContext): Observable<ResponseContext> {
8-
let method = request.getHttpMethod().toString();
9-
let body = request.getBody();
10-
11-
const resultPromise = fetch(request.getUrl(), {
12-
method: method,
13-
body: body as any,
8+
const resultPromise = sendBufferedRequest(request.getUrl(), {
9+
method: request.getHttpMethod().toString(),
10+
body: request.getBody(),
1411
headers: request.getHeaders(),
1512
agent: request.getAgent(),
16-
}).then((resp: any) => {
17-
const headers: { [name: string]: string } = {};
18-
resp.headers.forEach((value: string, name: string) => {
19-
headers[name] = value;
20-
});
21-
13+
}).then((response) => {
2214
const body = {
23-
text: () => resp.text(),
24-
binary: () => resp.buffer()
15+
text: () => response.text(),
16+
binary: () => response.binary()
2517
};
26-
return new ResponseContext(resp.status, headers, body);
18+
return new ResponseContext(response.status, response.headers, body);
2719
});
2820

2921
return from<Promise<ResponseContext>>(resultPromise);

0 commit comments

Comments
 (0)