Skip to content

Commit b4299dd

Browse files
authored
Merge pull request #69 from teacoder-team/dev
fix: resolve build errors
2 parents ea5905a + 27a35bf commit b4299dd

3 files changed

Lines changed: 55 additions & 3 deletions

File tree

packages/nestjs-yookassa/dist/common/interfaces/yookassa-options.interface.d.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,49 @@ export type YookassaModuleOptions = {
1212
* Ключ API для аутентификации в YooKassa.
1313
*/
1414
apiKey: string;
15+
/**
16+
* Настройки HTTP-прокси для отправки запросов.
17+
*
18+
* Используется в случаях, когда запросы к YooKassa должны идти
19+
* через российский IP — например, если сервер находится за границей.
20+
*
21+
* Пример простого подключения:
22+
* {
23+
* host: '192.168.1.10',
24+
* port: 8888,
25+
* protocol: 'http'
26+
* }
27+
*/
28+
proxy?: {
29+
/**
30+
* Хост или IPv4-адрес прокси-сервера.
31+
* Например: "91.218.114.206"
32+
*/
33+
host: string;
34+
/**
35+
* Порт, на котором работает прокси.
36+
* Для tinyproxy обычно 8888.
37+
*/
38+
port: number;
39+
/**
40+
* Протокол для подключения к прокси.
41+
* Почти всегда "http", т.к. tinyproxy не использует HTTPS.
42+
*/
43+
protocol?: 'http' | 'https';
44+
/**
45+
* Данные для авторизации на прокси (необязательно).
46+
*
47+
* Используется ТОЛЬКО если прокси защищён логином и паролем.
48+
* В tinyproxy по умолчанию не нужно.
49+
*
50+
* Пример:
51+
* auth: { username: "user", password: "pass" }
52+
*/
53+
auth?: {
54+
username: string;
55+
password: string;
56+
};
57+
};
1558
};
1659
/**
1760
* Тип для асинхронной настройки YooKassa.

packages/nestjs-yookassa/dist/core/http/yookassa.http-client.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const common_1 = require("@nestjs/common");
2222
const interfaces_1 = require("../../common/interfaces");
2323
let YookassaHttpClient = class YookassaHttpClient {
2424
constructor(config, httpService) {
25+
var _a;
2526
this.config = config;
2627
this.httpService = httpService;
2728
const client = this.httpService.axiosRef;
@@ -32,13 +33,21 @@ let YookassaHttpClient = class YookassaHttpClient {
3233
password: this.config.apiKey
3334
};
3435
client.defaults.headers.common['Content-Type'] = 'application/json';
36+
if (this.config.proxy) {
37+
client.defaults.proxy = {
38+
host: this.config.proxy.host,
39+
port: this.config.proxy.port,
40+
protocol: (_a = this.config.proxy.protocol) !== null && _a !== void 0 ? _a : 'http',
41+
auth: this.config.proxy.auth
42+
};
43+
console.log(`[YooKassa] Proxy enabled → ${this.config.proxy.host}:${this.config.proxy.port}`);
44+
}
3545
}
3646
async request(options) {
3747
var _a, _b, _c, _d, _e;
3848
try {
3949
options.headers = Object.assign(Object.assign({}, options.headers), { 'Idempotence-Key': (0, crypto_1.randomUUID)() });
40-
const $res = this.httpService.request(options);
41-
const res = await (0, rxjs_1.firstValueFrom)($res);
50+
const res = await (0, rxjs_1.firstValueFrom)(this.httpService.request(options));
4251
return res.data;
4352
}
4453
catch (error) {

packages/nestjs-yookassa/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nestjs-yookassa",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "A NestJS library for integrating with YooKassa API",
55
"keywords": [
66
"nest",

0 commit comments

Comments
 (0)