discogs-marketplace-api-nodejs 1.9.1 → 1.9.3
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 +3 -1
- package/dist/marketplace.js +5 -5
- package/package.json +27 -21
package/README.MD
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
# Discogs Marketplace API NodeJS
|
|
1
|
+
# Discogs Marketplace API NodeJS
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/discogs-marketplace-api-nodejs)  [](https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS/blob/master/LICENSE) [](https://www.paypal.me/KirianCaumes)
|
|
2
4
|
|
|
3
5
|
Another (better ?) NodeJs library to fetch data from Discogs marketplace. 💿
|
|
4
6
|
|
package/dist/marketplace.js
CHANGED
|
@@ -41,7 +41,7 @@ class Marketplace {
|
|
|
41
41
|
}),
|
|
42
42
|
].join('?');
|
|
43
43
|
/** Result got by different strategy type */
|
|
44
|
-
const result = await (
|
|
44
|
+
const result = await (() => {
|
|
45
45
|
switch (strategy) {
|
|
46
46
|
case 'fetch':
|
|
47
47
|
return this.getResultWithFetch({
|
|
@@ -125,13 +125,14 @@ class Marketplace {
|
|
|
125
125
|
* @param url Url
|
|
126
126
|
*/
|
|
127
127
|
static async getResultWithFetch({ input: { page, limit, searchValue, searchType }, dependencies: { url }, }) {
|
|
128
|
-
var _a, _b
|
|
128
|
+
var _a, _b;
|
|
129
129
|
const { data: bodyHTML, status } = await axios_1.default.get(url, {
|
|
130
130
|
headers: {
|
|
131
131
|
// cspell: disable-next-line
|
|
132
132
|
'X-PJAX': 'true',
|
|
133
133
|
'User-Agent': new user_agents_1.default({ platform: 'Win32' }).toString(),
|
|
134
134
|
},
|
|
135
|
+
validateStatus: () => true,
|
|
135
136
|
});
|
|
136
137
|
/** Generate document */
|
|
137
138
|
const { document } = (0, linkedom_1.parseHTML)(bodyHTML);
|
|
@@ -139,7 +140,7 @@ class Marketplace {
|
|
|
139
140
|
if (status >= 400) {
|
|
140
141
|
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
141
142
|
throw {
|
|
142
|
-
message: (
|
|
143
|
+
message: ((_b = (_a = document === null || document === void 0 ? void 0 : document.querySelector('h1 + p')) === null || _a === void 0 ? void 0 : _a.innerHTML) === null || _b === void 0 ? void 0 : _b.trim()) || 'An error occurred',
|
|
143
144
|
code: status,
|
|
144
145
|
};
|
|
145
146
|
}
|
|
@@ -155,7 +156,6 @@ class Marketplace {
|
|
|
155
156
|
* @param url Url
|
|
156
157
|
*/
|
|
157
158
|
static async getResultWithBrowser({ input: { page, limit, searchValue, searchType }, dependencies: { url }, }) {
|
|
158
|
-
var _a;
|
|
159
159
|
/** Init browser */
|
|
160
160
|
const browser = await playwright_chromium_1.chromium.launch({
|
|
161
161
|
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gl-drawing-for-tests'],
|
|
@@ -195,7 +195,7 @@ class Marketplace {
|
|
|
195
195
|
if (status >= 400) {
|
|
196
196
|
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
197
197
|
throw {
|
|
198
|
-
message: (
|
|
198
|
+
message: (await browserPage.evaluate(() => { var _a, _b; return (_b = (_a = document === null || document === void 0 ? void 0 : document.querySelector('h1 + p')) === null || _a === void 0 ? void 0 : _a.innerHTML) === null || _b === void 0 ? void 0 : _b.trim(); })) || 'An error occurred',
|
|
199
199
|
code: status,
|
|
200
200
|
};
|
|
201
201
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discogs-marketplace-api-nodejs",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "Another (better ?) NodeJs library to fetch data from Discogs marketplace",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"discogs",
|
|
@@ -31,38 +31,44 @@
|
|
|
31
31
|
"main": "dist/index.js",
|
|
32
32
|
"types": "dist/index.d.ts",
|
|
33
33
|
"engines": {
|
|
34
|
-
"node": ">=
|
|
34
|
+
"node": ">=16.0.0"
|
|
35
35
|
},
|
|
36
|
+
"funding": [
|
|
37
|
+
{
|
|
38
|
+
"type": "paypal",
|
|
39
|
+
"url": "https://www.paypal.me/KirianCaumes"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
36
42
|
"dependencies": {
|
|
37
|
-
"axios": "^1.6.
|
|
38
|
-
"linkedom": "^0.16.
|
|
39
|
-
"playwright-chromium": "^1.
|
|
40
|
-
"user-agents": "^1.1.
|
|
43
|
+
"axios": "^1.6.8",
|
|
44
|
+
"linkedom": "^0.16.11",
|
|
45
|
+
"playwright-chromium": "^1.43.1",
|
|
46
|
+
"user-agents": "^1.1.186"
|
|
41
47
|
},
|
|
42
48
|
"devDependencies": {
|
|
43
|
-
"@types/jest": "^29.5.
|
|
44
|
-
"@types/node": "^
|
|
49
|
+
"@types/jest": "^29.5.12",
|
|
50
|
+
"@types/node": "^20.12.7",
|
|
45
51
|
"@types/user-agents": "^1.0.4",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
47
|
-
"@typescript-eslint/parser": "^
|
|
48
|
-
"cspell": "^8.
|
|
49
|
-
"eslint": "^8.
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^7.7.1",
|
|
53
|
+
"@typescript-eslint/parser": "^7.7.1",
|
|
54
|
+
"cspell": "^8.7.0",
|
|
55
|
+
"eslint": "^8.57.0",
|
|
50
56
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
51
|
-
"eslint-config-airbnb-typescript": "^
|
|
57
|
+
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
52
58
|
"eslint-config-prettier": "^9.1.0",
|
|
53
59
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
54
60
|
"eslint-plugin-import": "^2.29.1",
|
|
55
|
-
"eslint-plugin-jsdoc": "^48.
|
|
56
|
-
"husky": "^
|
|
61
|
+
"eslint-plugin-jsdoc": "^48.2.3",
|
|
62
|
+
"husky": "^9.0.11",
|
|
57
63
|
"jest": "^29.7.0",
|
|
58
|
-
"knip": "^
|
|
59
|
-
"lint-staged": "^15.2.
|
|
60
|
-
"nodemon": "^3.0
|
|
61
|
-
"prettier": "^3.
|
|
64
|
+
"knip": "^5.11.0",
|
|
65
|
+
"lint-staged": "^15.2.2",
|
|
66
|
+
"nodemon": "^3.1.0",
|
|
67
|
+
"prettier": "^3.2.5",
|
|
62
68
|
"rimraf": "^5.0.5",
|
|
63
|
-
"ts-jest": "^29.1.
|
|
69
|
+
"ts-jest": "^29.1.2",
|
|
64
70
|
"tsc-alias": "^1.8.8",
|
|
65
71
|
"tsconfig-paths": "^4.2.0",
|
|
66
|
-
"typescript": "^5.
|
|
72
|
+
"typescript": "^5.4.5"
|
|
67
73
|
}
|
|
68
74
|
}
|