feedscout 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -7
- package/dist/blogrolls/index.cjs +9 -3
- package/dist/blogrolls/index.d.cts +1 -1
- package/dist/blogrolls/index.d.ts +1 -1
- package/dist/blogrolls/index.js +9 -3
- package/dist/common/discover/utils.cjs +26 -0
- package/dist/common/discover/utils.js +26 -1
- package/dist/common/locales.cjs +1 -0
- package/dist/common/locales.js +1 -0
- package/dist/common/types.d.cts +7 -5
- package/dist/common/types.d.ts +7 -5
- package/dist/common/uris/headers/index.cjs +6 -3
- package/dist/common/uris/headers/index.js +6 -3
- package/dist/common/uris/index.cjs +2 -0
- package/dist/common/uris/index.js +2 -0
- package/dist/common/uris/platform/index.cjs +12 -0
- package/dist/common/uris/platform/index.js +11 -0
- package/dist/common/uris/platform/types.d.cts +11 -0
- package/dist/common/uris/platform/types.d.ts +11 -0
- package/dist/common/utils.cjs +10 -0
- package/dist/common/utils.d.cts +9 -0
- package/dist/common/utils.d.ts +9 -0
- package/dist/common/utils.js +7 -1
- package/dist/feeds/defaults.cjs +43 -0
- package/dist/feeds/defaults.d.cts +3 -1
- package/dist/feeds/defaults.d.ts +3 -1
- package/dist/feeds/defaults.js +44 -1
- package/dist/feeds/index.cjs +10 -3
- package/dist/feeds/index.d.cts +1 -1
- package/dist/feeds/index.d.ts +1 -1
- package/dist/feeds/index.js +11 -4
- package/dist/feeds/platform/handlers/behance.cjs +45 -0
- package/dist/feeds/platform/handlers/behance.js +45 -0
- package/dist/feeds/platform/handlers/blogspot.cjs +24 -0
- package/dist/feeds/platform/handlers/blogspot.js +23 -0
- package/dist/feeds/platform/handlers/bluesky.cjs +18 -0
- package/dist/feeds/platform/handlers/bluesky.js +18 -0
- package/dist/feeds/platform/handlers/dailymotion.cjs +66 -0
- package/dist/feeds/platform/handlers/dailymotion.js +66 -0
- package/dist/feeds/platform/handlers/deviantart.cjs +50 -0
- package/dist/feeds/platform/handlers/deviantart.js +50 -0
- package/dist/feeds/platform/handlers/devto.cjs +44 -0
- package/dist/feeds/platform/handlers/devto.js +44 -0
- package/dist/feeds/platform/handlers/github.cjs +89 -0
- package/dist/feeds/platform/handlers/github.js +89 -0
- package/dist/feeds/platform/handlers/githubGist.cjs +42 -0
- package/dist/feeds/platform/handlers/githubGist.js +42 -0
- package/dist/feeds/platform/handlers/gitlab.cjs +53 -0
- package/dist/feeds/platform/handlers/gitlab.js +53 -0
- package/dist/feeds/platform/handlers/kickstarter.cjs +18 -0
- package/dist/feeds/platform/handlers/kickstarter.js +18 -0
- package/dist/feeds/platform/handlers/lobsters.cjs +34 -0
- package/dist/feeds/platform/handlers/lobsters.js +34 -0
- package/dist/feeds/platform/handlers/medium.cjs +47 -0
- package/dist/feeds/platform/handlers/medium.js +47 -0
- package/dist/feeds/platform/handlers/pinterest.cjs +48 -0
- package/dist/feeds/platform/handlers/pinterest.js +48 -0
- package/dist/feeds/platform/handlers/producthunt.cjs +22 -0
- package/dist/feeds/platform/handlers/producthunt.js +22 -0
- package/dist/feeds/platform/handlers/reddit.cjs +47 -0
- package/dist/feeds/platform/handlers/reddit.js +47 -0
- package/dist/feeds/platform/handlers/soundcloud.cjs +37 -0
- package/dist/feeds/platform/handlers/soundcloud.js +37 -0
- package/dist/feeds/platform/handlers/substack.cjs +15 -0
- package/dist/feeds/platform/handlers/substack.js +15 -0
- package/dist/feeds/platform/handlers/tumblr.cjs +18 -0
- package/dist/feeds/platform/handlers/tumblr.js +18 -0
- package/dist/feeds/platform/handlers/wordpress.cjs +30 -0
- package/dist/feeds/platform/handlers/wordpress.js +30 -0
- package/dist/feeds/platform/handlers/youtube.cjs +56 -0
- package/dist/feeds/platform/handlers/youtube.js +56 -0
- package/dist/feeds.cjs +1 -0
- package/dist/feeds.d.cts +2 -2
- package/dist/feeds.d.ts +2 -2
- package/dist/feeds.js +2 -2
- package/dist/hubs/discover/index.cjs +7 -6
- package/dist/hubs/discover/index.js +5 -4
- package/dist/hubs/discover/types.d.cts +2 -1
- package/dist/hubs/discover/types.d.ts +2 -1
- package/dist/hubs/headers/index.cjs +3 -3
- package/dist/hubs/headers/index.js +3 -3
- package/dist/hubs/html/index.cjs +3 -3
- package/dist/hubs/html/index.js +3 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/utils.cjs +8 -0
- package/dist/utils.d.cts +2 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +3 -0
- package/package.json +32 -32
- package/dist/adapters.cjs +0 -6
- package/dist/adapters.d.cts +0 -2
- package/dist/adapters.d.ts +0 -2
- package/dist/adapters.js +0 -3
- package/dist/common/discover/adapters.cjs +0 -76
- package/dist/common/discover/adapters.d.cts +0 -10
- package/dist/common/discover/adapters.d.ts +0 -10
- package/dist/common/discover/adapters.js +0 -72
package/dist/hubs/html/index.cjs
CHANGED
|
@@ -9,7 +9,7 @@ const htmlOptions = {
|
|
|
9
9
|
anchorIgnoredUris: [],
|
|
10
10
|
anchorLabels: []
|
|
11
11
|
};
|
|
12
|
-
const discoverHubsFromHtml = (content, baseUrl) => {
|
|
12
|
+
const discoverHubsFromHtml = (content, baseUrl, normalizeUrlFn = require_utils.normalizeUrl) => {
|
|
13
13
|
const hubUris = require_index.discoverUrisFromHtml(content, {
|
|
14
14
|
...htmlOptions,
|
|
15
15
|
linkSelectors: hubSelector
|
|
@@ -19,9 +19,9 @@ const discoverHubsFromHtml = (content, baseUrl) => {
|
|
|
19
19
|
...htmlOptions,
|
|
20
20
|
linkSelectors: selfSelector
|
|
21
21
|
});
|
|
22
|
-
const topic = selfUris[0] ?
|
|
22
|
+
const topic = selfUris[0] ? normalizeUrlFn(selfUris[0], baseUrl) : baseUrl;
|
|
23
23
|
return hubUris.map((hub) => ({
|
|
24
|
-
hub:
|
|
24
|
+
hub: normalizeUrlFn(hub, baseUrl),
|
|
25
25
|
topic
|
|
26
26
|
}));
|
|
27
27
|
};
|
package/dist/hubs/html/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const htmlOptions = {
|
|
|
9
9
|
anchorIgnoredUris: [],
|
|
10
10
|
anchorLabels: []
|
|
11
11
|
};
|
|
12
|
-
const discoverHubsFromHtml = (content, baseUrl) => {
|
|
12
|
+
const discoverHubsFromHtml = (content, baseUrl, normalizeUrlFn = normalizeUrl) => {
|
|
13
13
|
const hubUris = discoverUrisFromHtml(content, {
|
|
14
14
|
...htmlOptions,
|
|
15
15
|
linkSelectors: hubSelector
|
|
@@ -19,9 +19,9 @@ const discoverHubsFromHtml = (content, baseUrl) => {
|
|
|
19
19
|
...htmlOptions,
|
|
20
20
|
linkSelectors: selfSelector
|
|
21
21
|
});
|
|
22
|
-
const topic = selfUris[0] ?
|
|
22
|
+
const topic = selfUris[0] ? normalizeUrlFn(selfUris[0], baseUrl) : baseUrl;
|
|
23
23
|
return hubUris.map((hub) => ({
|
|
24
|
-
hub:
|
|
24
|
+
hub: normalizeUrlFn(hub, baseUrl),
|
|
25
25
|
topic
|
|
26
26
|
}));
|
|
27
27
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DiscoverExtractFn, DiscoverFetchFn, DiscoverFetchFnOptions, DiscoverFetchFnResponse, DiscoverInput, DiscoverInputObject, DiscoverMethodsConfig, DiscoverNormalizeUrlFn, DiscoverOptions, DiscoverProgress,
|
|
1
|
+
import { DiscoverExtractFn, DiscoverFetchFn, DiscoverFetchFnOptions, DiscoverFetchFnResponse, DiscoverInput, DiscoverInputObject, DiscoverMethodsConfig, DiscoverNormalizeUrlFn, DiscoverOnProgressFn, DiscoverOptions, DiscoverProgress, DiscoverResult } from "./common/types.cjs";
|
|
2
2
|
import { discoverBlogrolls } from "./blogrolls/index.cjs";
|
|
3
3
|
import { discoverFeeds } from "./feeds/index.cjs";
|
|
4
4
|
import { discoverHubs } from "./hubs/discover/index.cjs";
|
|
5
|
-
export { type DiscoverExtractFn, type DiscoverFetchFn, type DiscoverFetchFnOptions, type DiscoverFetchFnResponse, type DiscoverInput, type DiscoverInputObject, type DiscoverMethodsConfig, type DiscoverNormalizeUrlFn, type
|
|
5
|
+
export { type DiscoverExtractFn, type DiscoverFetchFn, type DiscoverFetchFnOptions, type DiscoverFetchFnResponse, type DiscoverInput, type DiscoverInputObject, type DiscoverMethodsConfig, type DiscoverNormalizeUrlFn, type DiscoverOnProgressFn, type DiscoverOptions, type DiscoverProgress, type DiscoverResult, discoverBlogrolls, discoverFeeds, discoverHubs };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DiscoverExtractFn, DiscoverFetchFn, DiscoverFetchFnOptions, DiscoverFetchFnResponse, DiscoverInput, DiscoverInputObject, DiscoverMethodsConfig, DiscoverNormalizeUrlFn, DiscoverOptions, DiscoverProgress,
|
|
1
|
+
import { DiscoverExtractFn, DiscoverFetchFn, DiscoverFetchFnOptions, DiscoverFetchFnResponse, DiscoverInput, DiscoverInputObject, DiscoverMethodsConfig, DiscoverNormalizeUrlFn, DiscoverOnProgressFn, DiscoverOptions, DiscoverProgress, DiscoverResult } from "./common/types.js";
|
|
2
2
|
import { discoverBlogrolls } from "./blogrolls/index.js";
|
|
3
3
|
import { discoverFeeds } from "./feeds/index.js";
|
|
4
4
|
import { discoverHubs } from "./hubs/discover/index.js";
|
|
5
|
-
export { type DiscoverExtractFn, type DiscoverFetchFn, type DiscoverFetchFnOptions, type DiscoverFetchFnResponse, type DiscoverInput, type DiscoverInputObject, type DiscoverMethodsConfig, type DiscoverNormalizeUrlFn, type
|
|
5
|
+
export { type DiscoverExtractFn, type DiscoverFetchFn, type DiscoverFetchFnOptions, type DiscoverFetchFnResponse, type DiscoverInput, type DiscoverInputObject, type DiscoverMethodsConfig, type DiscoverNormalizeUrlFn, type DiscoverOnProgressFn, type DiscoverOptions, type DiscoverProgress, type DiscoverResult, discoverBlogrolls, discoverFeeds, discoverHubs };
|
package/dist/utils.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const require_utils = require('./common/utils.cjs');
|
|
2
|
+
|
|
3
|
+
exports.anyWordMatchesAnyOf = require_utils.anyWordMatchesAnyOf;
|
|
4
|
+
exports.endsWithAnyOf = require_utils.endsWithAnyOf;
|
|
5
|
+
exports.includesAnyOf = require_utils.includesAnyOf;
|
|
6
|
+
exports.isAnyOf = require_utils.isAnyOf;
|
|
7
|
+
exports.isHostOf = require_utils.isHostOf;
|
|
8
|
+
exports.isSubdomainOf = require_utils.isSubdomainOf;
|
package/dist/utils.d.cts
ADDED
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "feedscout",
|
|
3
3
|
"description": "Advanced feed autodiscovery for JavaScript. Collect feed information from any webpage using multiple discovery methods.",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/macieklamberski/feedscout.git"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://feedscout.dev",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/macieklamberski/feedscout/issues"
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Maciej Lamberski",
|
|
14
|
+
"sideEffects": false,
|
|
4
15
|
"keywords": [
|
|
5
16
|
"rss",
|
|
6
17
|
"rss-autodiscovery",
|
|
@@ -12,20 +23,7 @@
|
|
|
12
23
|
"rss-discovery",
|
|
13
24
|
"feed-locator"
|
|
14
25
|
],
|
|
15
|
-
"repository": {
|
|
16
|
-
"type": "git",
|
|
17
|
-
"url": "https://github.com/macieklamberski/feedscout.git"
|
|
18
|
-
},
|
|
19
|
-
"homepage": "https://github.com/macieklamberski/feedscout",
|
|
20
|
-
"bugs": {
|
|
21
|
-
"url": "https://github.com/macieklamberski/feedscout/issues"
|
|
22
|
-
},
|
|
23
|
-
"author": "Maciej Lamberski",
|
|
24
|
-
"license": "MIT",
|
|
25
26
|
"type": "module",
|
|
26
|
-
"files": [
|
|
27
|
-
"dist"
|
|
28
|
-
],
|
|
29
27
|
"exports": {
|
|
30
28
|
".": {
|
|
31
29
|
"import": {
|
|
@@ -67,16 +65,6 @@
|
|
|
67
65
|
"default": "./dist/hubs.cjs"
|
|
68
66
|
}
|
|
69
67
|
},
|
|
70
|
-
"./adapters": {
|
|
71
|
-
"import": {
|
|
72
|
-
"types": "./dist/adapters.d.ts",
|
|
73
|
-
"default": "./dist/adapters.js"
|
|
74
|
-
},
|
|
75
|
-
"require": {
|
|
76
|
-
"types": "./dist/adapters.d.cts",
|
|
77
|
-
"default": "./dist/adapters.cjs"
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
68
|
"./methods": {
|
|
81
69
|
"import": {
|
|
82
70
|
"types": "./dist/methods.d.ts",
|
|
@@ -87,24 +75,36 @@
|
|
|
87
75
|
"default": "./dist/methods.cjs"
|
|
88
76
|
}
|
|
89
77
|
},
|
|
78
|
+
"./utils": {
|
|
79
|
+
"import": {
|
|
80
|
+
"types": "./dist/utils.d.ts",
|
|
81
|
+
"default": "./dist/utils.js"
|
|
82
|
+
},
|
|
83
|
+
"require": {
|
|
84
|
+
"types": "./dist/utils.d.cts",
|
|
85
|
+
"default": "./dist/utils.cjs"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
90
88
|
"./package.json": "./package.json"
|
|
91
89
|
},
|
|
90
|
+
"files": [
|
|
91
|
+
"dist"
|
|
92
|
+
],
|
|
92
93
|
"scripts": {
|
|
93
94
|
"prepare": "lefthook install",
|
|
94
|
-
"build": "tsdown src/exports/index.ts src/exports/feeds.ts src/exports/blogrolls.ts src/exports/hubs.ts src/exports/
|
|
95
|
+
"build": "tsdown src/exports/index.ts src/exports/feeds.ts src/exports/blogrolls.ts src/exports/hubs.ts src/exports/methods.ts src/exports/utils.ts --format cjs,esm --dts --clean --unbundle --no-fixed-extension",
|
|
95
96
|
"docs:dev": "vitepress dev docs",
|
|
96
|
-
"docs:build": "vitepress build docs"
|
|
97
|
-
"docs:preview": "vitepress preview docs"
|
|
97
|
+
"docs:build": "vitepress build docs"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"feedsmith": "^2.
|
|
101
|
-
"htmlparser2": "^10.
|
|
100
|
+
"feedsmith": "^2.9.0",
|
|
101
|
+
"htmlparser2": "^10.1.0"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
|
-
"@types/bun": "^1.3.
|
|
105
|
-
"kvalita": "1.
|
|
106
|
-
"tsdown": "^0.
|
|
104
|
+
"@types/bun": "^1.3.6",
|
|
105
|
+
"kvalita": "1.9.0",
|
|
106
|
+
"tsdown": "^0.20.1",
|
|
107
107
|
"vitepress": "^1.6.4"
|
|
108
108
|
},
|
|
109
|
-
"version": "1.
|
|
109
|
+
"version": "1.2.0"
|
|
110
110
|
}
|
package/dist/adapters.cjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const require_adapters = require('./common/discover/adapters.cjs');
|
|
2
|
-
|
|
3
|
-
exports.createAxiosAdapter = require_adapters.createAxiosAdapter;
|
|
4
|
-
exports.createGotAdapter = require_adapters.createGotAdapter;
|
|
5
|
-
exports.createKyAdapter = require_adapters.createKyAdapter;
|
|
6
|
-
exports.createNativeFetchAdapter = require_adapters.createNativeFetchAdapter;
|
package/dist/adapters.d.cts
DELETED
package/dist/adapters.d.ts
DELETED
package/dist/adapters.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/common/discover/adapters.ts
|
|
3
|
-
const createNativeFetchAdapter = (baseOptions) => {
|
|
4
|
-
return async (url, options) => {
|
|
5
|
-
const response = await fetch(url, {
|
|
6
|
-
...baseOptions,
|
|
7
|
-
method: options?.method || "GET",
|
|
8
|
-
headers: {
|
|
9
|
-
...baseOptions?.headers,
|
|
10
|
-
...options?.headers
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
return {
|
|
14
|
-
headers: response.headers,
|
|
15
|
-
body: await response.text(),
|
|
16
|
-
url: response.url,
|
|
17
|
-
status: response.status,
|
|
18
|
-
statusText: response.statusText
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
const createGotAdapter = (gotInstance) => {
|
|
23
|
-
return async (url, options) => {
|
|
24
|
-
const response = await gotInstance(url, {
|
|
25
|
-
method: options?.method || "GET",
|
|
26
|
-
headers: options?.headers,
|
|
27
|
-
throwHttpErrors: false
|
|
28
|
-
});
|
|
29
|
-
return {
|
|
30
|
-
headers: new Headers(response.headers),
|
|
31
|
-
body: response.body,
|
|
32
|
-
url: response.url,
|
|
33
|
-
status: response.statusCode,
|
|
34
|
-
statusText: response.statusMessage
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
const createAxiosAdapter = (axiosInstance) => {
|
|
39
|
-
return async (url, options) => {
|
|
40
|
-
const response = await axiosInstance({
|
|
41
|
-
url,
|
|
42
|
-
method: options?.method || "GET",
|
|
43
|
-
headers: options?.headers,
|
|
44
|
-
validateStatus: () => true
|
|
45
|
-
});
|
|
46
|
-
return {
|
|
47
|
-
headers: new Headers(response.headers),
|
|
48
|
-
body: response.data,
|
|
49
|
-
url: response.request?.res?.responseUrl || url,
|
|
50
|
-
status: response.status,
|
|
51
|
-
statusText: response.statusText
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
const createKyAdapter = (kyInstance) => {
|
|
56
|
-
return async (url, options) => {
|
|
57
|
-
const response = await kyInstance(url, {
|
|
58
|
-
method: options?.method || "GET",
|
|
59
|
-
headers: options?.headers,
|
|
60
|
-
throwHttpErrors: false
|
|
61
|
-
});
|
|
62
|
-
return {
|
|
63
|
-
headers: response.headers,
|
|
64
|
-
body: await response.text(),
|
|
65
|
-
url: response.url,
|
|
66
|
-
status: response.status,
|
|
67
|
-
statusText: response.statusText
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
//#endregion
|
|
73
|
-
exports.createAxiosAdapter = createAxiosAdapter;
|
|
74
|
-
exports.createGotAdapter = createGotAdapter;
|
|
75
|
-
exports.createKyAdapter = createKyAdapter;
|
|
76
|
-
exports.createNativeFetchAdapter = createNativeFetchAdapter;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { DiscoverFetchFn } from "../types.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/common/discover/adapters.d.ts
|
|
4
|
-
type AnyInstance = any;
|
|
5
|
-
declare const createNativeFetchAdapter: (baseOptions?: RequestInit) => DiscoverFetchFn;
|
|
6
|
-
declare const createGotAdapter: (gotInstance: AnyInstance) => DiscoverFetchFn;
|
|
7
|
-
declare const createAxiosAdapter: (axiosInstance: AnyInstance) => DiscoverFetchFn;
|
|
8
|
-
declare const createKyAdapter: (kyInstance: AnyInstance) => DiscoverFetchFn;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { createAxiosAdapter, createGotAdapter, createKyAdapter, createNativeFetchAdapter };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { DiscoverFetchFn } from "../types.js";
|
|
2
|
-
|
|
3
|
-
//#region src/common/discover/adapters.d.ts
|
|
4
|
-
type AnyInstance = any;
|
|
5
|
-
declare const createNativeFetchAdapter: (baseOptions?: RequestInit) => DiscoverFetchFn;
|
|
6
|
-
declare const createGotAdapter: (gotInstance: AnyInstance) => DiscoverFetchFn;
|
|
7
|
-
declare const createAxiosAdapter: (axiosInstance: AnyInstance) => DiscoverFetchFn;
|
|
8
|
-
declare const createKyAdapter: (kyInstance: AnyInstance) => DiscoverFetchFn;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { createAxiosAdapter, createGotAdapter, createKyAdapter, createNativeFetchAdapter };
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
//#region src/common/discover/adapters.ts
|
|
2
|
-
const createNativeFetchAdapter = (baseOptions) => {
|
|
3
|
-
return async (url, options) => {
|
|
4
|
-
const response = await fetch(url, {
|
|
5
|
-
...baseOptions,
|
|
6
|
-
method: options?.method || "GET",
|
|
7
|
-
headers: {
|
|
8
|
-
...baseOptions?.headers,
|
|
9
|
-
...options?.headers
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
return {
|
|
13
|
-
headers: response.headers,
|
|
14
|
-
body: await response.text(),
|
|
15
|
-
url: response.url,
|
|
16
|
-
status: response.status,
|
|
17
|
-
statusText: response.statusText
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
const createGotAdapter = (gotInstance) => {
|
|
22
|
-
return async (url, options) => {
|
|
23
|
-
const response = await gotInstance(url, {
|
|
24
|
-
method: options?.method || "GET",
|
|
25
|
-
headers: options?.headers,
|
|
26
|
-
throwHttpErrors: false
|
|
27
|
-
});
|
|
28
|
-
return {
|
|
29
|
-
headers: new Headers(response.headers),
|
|
30
|
-
body: response.body,
|
|
31
|
-
url: response.url,
|
|
32
|
-
status: response.statusCode,
|
|
33
|
-
statusText: response.statusMessage
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
const createAxiosAdapter = (axiosInstance) => {
|
|
38
|
-
return async (url, options) => {
|
|
39
|
-
const response = await axiosInstance({
|
|
40
|
-
url,
|
|
41
|
-
method: options?.method || "GET",
|
|
42
|
-
headers: options?.headers,
|
|
43
|
-
validateStatus: () => true
|
|
44
|
-
});
|
|
45
|
-
return {
|
|
46
|
-
headers: new Headers(response.headers),
|
|
47
|
-
body: response.data,
|
|
48
|
-
url: response.request?.res?.responseUrl || url,
|
|
49
|
-
status: response.status,
|
|
50
|
-
statusText: response.statusText
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
const createKyAdapter = (kyInstance) => {
|
|
55
|
-
return async (url, options) => {
|
|
56
|
-
const response = await kyInstance(url, {
|
|
57
|
-
method: options?.method || "GET",
|
|
58
|
-
headers: options?.headers,
|
|
59
|
-
throwHttpErrors: false
|
|
60
|
-
});
|
|
61
|
-
return {
|
|
62
|
-
headers: response.headers,
|
|
63
|
-
body: await response.text(),
|
|
64
|
-
url: response.url,
|
|
65
|
-
status: response.status,
|
|
66
|
-
statusText: response.statusText
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
//#endregion
|
|
72
|
-
export { createAxiosAdapter, createGotAdapter, createKyAdapter, createNativeFetchAdapter };
|