radiobrowser-api-client 0.1.2 → 0.1.4
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/dist/client.js +8 -2
- package/package.json +2 -1
- package/src/client.ts +6 -3
package/dist/client.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.RadioBrowserClient = void 0;
|
|
4
|
-
const axios_1 = require("axios");
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
5
8
|
const data_1 = require("./types/data");
|
|
6
9
|
const queries_1 = require("./types/queries");
|
|
7
10
|
const typescript_json_serializer_1 = require("typescript-json-serializer");
|
|
11
|
+
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
8
12
|
class RadioBrowserClient {
|
|
9
13
|
axios;
|
|
10
14
|
jsonSerializer;
|
|
@@ -14,9 +18,11 @@ class RadioBrowserClient {
|
|
|
14
18
|
* @param appVersion - Version of your application
|
|
15
19
|
*/
|
|
16
20
|
constructor(appName, appVersion) {
|
|
17
|
-
this.axios =
|
|
21
|
+
this.axios = axios_1.default.create({
|
|
18
22
|
headers: { 'User-Agent': `${appName}/${appVersion}` },
|
|
23
|
+
transformResponse: [(data) => data],
|
|
19
24
|
});
|
|
25
|
+
(0, axios_retry_1.default)(this.axios, { retries: 3, retryDelay: (retryCount) => retryCount * 100 });
|
|
20
26
|
this.jsonSerializer = new typescript_json_serializer_1.JsonSerializer();
|
|
21
27
|
}
|
|
22
28
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "radiobrowser-api-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Client for Radio Browser API",
|
|
5
5
|
"homepage": "https://github.com/marioneq4958/radiobrowser-api-client",
|
|
6
6
|
"bugs": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
|
26
26
|
"@typescript-eslint/parser": "^7.4.0",
|
|
27
27
|
"axios": "^1.6.8",
|
|
28
|
+
"axios-retry": "^4.1.0",
|
|
28
29
|
"eslint": "^8.57.0",
|
|
29
30
|
"eslint-config-prettier": "^9.1.0",
|
|
30
31
|
"eslint-plugin-prettier": "^5.1.3",
|
package/src/client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import axios, { AxiosInstance } from 'axios';
|
|
2
2
|
import {
|
|
3
3
|
Codec,
|
|
4
4
|
Country,
|
|
@@ -28,9 +28,10 @@ import {
|
|
|
28
28
|
} from './types/queries';
|
|
29
29
|
import { ListOutputFormat, ObjectOutputFromat, StationsListOutputFormat } from './types/formats';
|
|
30
30
|
import { JsonSerializer } from 'typescript-json-serializer';
|
|
31
|
+
import axiosRetry from 'axios-retry';
|
|
31
32
|
|
|
32
33
|
export class RadioBrowserClient {
|
|
33
|
-
private readonly axios:
|
|
34
|
+
private readonly axios: AxiosInstance;
|
|
34
35
|
private readonly jsonSerializer: JsonSerializer;
|
|
35
36
|
|
|
36
37
|
/**
|
|
@@ -39,9 +40,11 @@ export class RadioBrowserClient {
|
|
|
39
40
|
* @param appVersion - Version of your application
|
|
40
41
|
*/
|
|
41
42
|
constructor(appName: string, appVersion: string) {
|
|
42
|
-
this.axios =
|
|
43
|
+
this.axios = axios.create({
|
|
43
44
|
headers: { 'User-Agent': `${appName}/${appVersion}` },
|
|
45
|
+
transformResponse: [(data) => data],
|
|
44
46
|
});
|
|
47
|
+
axiosRetry(this.axios, { retries: 3, retryDelay: (retryCount) => retryCount * 100 });
|
|
45
48
|
this.jsonSerializer = new JsonSerializer();
|
|
46
49
|
}
|
|
47
50
|
|