Compare View

switch
from
...
to
 
Commits (2)

Changes

Showing 4 changed files Side-by-side Diff

... ... @@ -6,6 +6,7 @@
6 6 "terminal_name": "PLEASE_CHANGE_ME",
7 7 "password": "PLEASE_CHANGE_ME",
8 8 "dump_request": true,
  9 + "method": "GET",
9 10 "callback": {
10 11 "port": 14000,
11 12 "url": "http://PLEASE_CHANGE_ME:14000",
lib/hit/prepaid-topup.js
... ... @@ -43,7 +43,9 @@ module.exports = async (xid, task) => {
43 43 xid,
44 44 endpointUrl,
45 45 params,
46   - fullEndpointUrl,
  46 + fullEndpointUrl: (!config.partner.method || config.partner.method === 'GET')
  47 + ? fullEndpointUrl
  48 + : endpointUrl,
47 49 });
48 50  
49 51 report(xid, {
... ... @@ -52,17 +54,25 @@ module.exports = async (xid, task) => {
52 54 message: {
53 55 xid,
54 56 msg: 'Sending request to partner',
  57 + method: config.partner.method || 'GET',
55 58 endpointUrl,
56 59 },
57 60 });
58 61  
59   - const response = await axios.get(endpointUrl, {
60   - headers: {
61   - 'User-Agent': 'KOMODO-GW-HTTPGETX',
62   - },
63   - timeout: config.partner.hit_timeout_ms || 60 * 1000,
64   - params,
65   - });
  62 + const response = config.partner.method === 'POST'
  63 + ? await axios.post(endpointUrl, new URLSearchParams(params), {
  64 + headers: {
  65 + 'User-Agent': 'KOMODO-GW-HTTPGETX',
  66 + },
  67 + timeout: config.partner.hit_timeout_ms || 60 * 1000,
  68 + })
  69 + : await axios.get(endpointUrl, {
  70 + headers: {
  71 + 'User-Agent': 'KOMODO-GW-HTTPGETX',
  72 + },
  73 + timeout: config.partner.hit_timeout_ms || 60 * 1000,
  74 + params,
  75 + });
66 76  
67 77 if (!response) {
68 78 const e = new Error(`${MODULE_NAME} 8CF4E04D: Empty response`);
... ... @@ -138,7 +148,7 @@ module.exports = async (xid, task) => {
138 148 dumpReqRes(
139 149 xid,
140 150 task,
141   - 'GET',
  151 + config.partner.method || 'GET',
142 152 endpointUrl,
143 153 params,
144 154 lastResponse && lastResponse.data,
1 1 {
2 2 "name": "komodo-gw-komodo-httpgetx",
3   - "version": "0.3.8",
  3 + "version": "0.3.9",
4 4 "lockfileVersion": 2,
5 5 "requires": true,
6 6 "packages": {
7 7 "": {
8 8 "name": "komodo-gw-komodo-httpgetx",
9   - "version": "0.3.8",
  9 + "version": "0.3.9",
10 10 "license": "ISC",
11 11 "dependencies": {
12 12 "axios": "^1.1.3",
1 1 {
2 2 "name": "komodo-gw-komodo-httpgetx",
3   - "version": "0.3.8",
  3 + "version": "0.3.9",
4 4 "description": "Komodo gateway to KOMODO HTTPGETX",
5 5 "main": "index.js",
6 6 "scripts": {