speedly 2.0.36 → 2.0.37
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.
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const axios_1 = __importDefault(require("axios"));
|
|
7
7
|
const translation_1 = __importDefault(require("./../model/translation"));
|
|
8
|
+
const TIMEOUT = 5000;
|
|
8
9
|
const getConfig_1 = __importDefault(require("./getConfig"));
|
|
9
10
|
const configs = { ...(0, getConfig_1.default)("translate") };
|
|
10
11
|
async function firstSuccessful(promises) {
|
|
@@ -35,7 +36,7 @@ exports.default = async (text = "unspecified text", lang = "fa") => {
|
|
|
35
36
|
return translationDoc.translatedText;
|
|
36
37
|
const translationPromises = [];
|
|
37
38
|
translationPromises.push((async () => {
|
|
38
|
-
const res = await axios_1.default.get(`https://655.mtis.workers.dev/translate?text=${encodeURIComponent(formattedText)}&source_lang=en&target_lang=${lang}`, { timeout:
|
|
39
|
+
const res = await axios_1.default.get(`https://655.mtis.workers.dev/translate?text=${encodeURIComponent(formattedText)}&source_lang=en&target_lang=${lang}`, { timeout: TIMEOUT });
|
|
39
40
|
if (!res.data?.response?.translated_text)
|
|
40
41
|
throw new Error("Translation failed");
|
|
41
42
|
return res.data.response.translated_text;
|
|
@@ -45,7 +46,7 @@ exports.default = async (text = "unspecified text", lang = "fa") => {
|
|
|
45
46
|
text: formattedText,
|
|
46
47
|
target: lang,
|
|
47
48
|
}, {
|
|
48
|
-
timeout:
|
|
49
|
+
timeout: TIMEOUT,
|
|
49
50
|
headers: {
|
|
50
51
|
"one-api-token": "783122:68a02b5c4dcee",
|
|
51
52
|
},
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const axios_1 = __importDefault(require("axios"));
|
|
7
7
|
const translation_1 = __importDefault(require("./../model/translation"));
|
|
8
|
+
const TIMEOUT = 5000;
|
|
8
9
|
const getConfig_1 = __importDefault(require("./getConfig"));
|
|
9
10
|
const configs = { ...(0, getConfig_1.default)("translate") };
|
|
10
11
|
async function firstSuccessful(promises) {
|
|
@@ -35,7 +36,7 @@ exports.default = async (text = "unspecified text", lang = "fa") => {
|
|
|
35
36
|
return translationDoc.translatedText;
|
|
36
37
|
const translationPromises = [];
|
|
37
38
|
translationPromises.push((async () => {
|
|
38
|
-
const res = await axios_1.default.get(`https://655.mtis.workers.dev/translate?text=${encodeURIComponent(formattedText)}&source_lang=en&target_lang=${lang}`, { timeout:
|
|
39
|
+
const res = await axios_1.default.get(`https://655.mtis.workers.dev/translate?text=${encodeURIComponent(formattedText)}&source_lang=en&target_lang=${lang}`, { timeout: TIMEOUT });
|
|
39
40
|
if (!res.data?.response?.translated_text)
|
|
40
41
|
throw new Error("Translation failed");
|
|
41
42
|
return res.data.response.translated_text;
|
|
@@ -45,7 +46,7 @@ exports.default = async (text = "unspecified text", lang = "fa") => {
|
|
|
45
46
|
text: formattedText,
|
|
46
47
|
target: lang,
|
|
47
48
|
}, {
|
|
48
|
-
timeout:
|
|
49
|
+
timeout: TIMEOUT,
|
|
49
50
|
headers: {
|
|
50
51
|
"one-api-token": "783122:68a02b5c4dcee",
|
|
51
52
|
},
|